DC motor

You will need:
- DC Motor
- Power diode
- TIP 120

Turn the motor on with this code:

  1. void setup() {                
  2.   pinMode(8, OUTPUT);    
  3. }
  4.  
  5. void loop() {
  6.   digitalWrite(8, HIGH); // Turn on motor
  7.   delay(5000);
  8.   digitalWrite(8, LOW); // Turn off motor
  9.   delay(5000);      
  10. }

Flex sensor

To get the values from the flex sensor you need a 22K resistor.

  1. void setup() {
  2.       Serial.begin(9600);
  3. }
  4.  
  5. void loop() {
  6.       int sensorValue = analogRead(A0);
  7.       Serial.println(sensorValue, DEC);
  8. }

See how the sensor can be use in a project like Bad posture by Ellen Sundh.