Monday, October 8, 2012

Midterm project progress 3

We`ve got the bend sensors to work on our own circuit!!!!!
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