Gabriella Levine

ongoing and past work

Lab 3 and beyond

MotorPlusLED flexSensor

Finally I rearranged the code from before and was able to get the LED to blink and the motor to spin when the flex sensor was touched. See the code on the next page

DC relayBlink from gabriella levine on Vimeo.

Here I use the Arduino and a stripped radioshack electrical outlet, this code is just set up to blink, but I’d like to use a heat sensor to … do something? (like power on the outlet).

Code for flexor sensor controlling LED and servoMotor:

#define POTPIN 0
#define LEDPIN 10
int servo = 11;

int val = 0;

void setup() {
Serial.begin(9600);
pinMode(LEDPIN, OUTPUT);
pinMode(servo, OUTPUT);
}

void loop() {
val = analogRead(POTPIN);    // read the value from the sensor

analogWrite(LEDPIN,val/4);
analogWrite(servo,val/4);
}

Leave a Reply