Sketch:
Screenshot:
This is the code:
//Array of analog pins
int flexPin[] = {0, 1, 2, 3};
void setup(){
//Connect to Serial Port 9600
Serial.begin(9600);
}
void loop () {
//Text that will show up on monitor
String toPrint = "sensor";
for (int i=0; i<4; i++) {
toPrint += i;
toPrint += ": ";
//Read the values of the four Flex Sensors and print it
toPrint += constrain(map(analogRead(flexPin[i]), 130, 275, 4, 13), 4, 13);
if (i < 3) toPrint += ", sensor";
}
//Print on serial port
Serial.println(toPrint);
delay(100);
}
No comments:
Post a Comment