Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. int analogPin = A0;
  2. int ledPin = 9;
  3.  
  4. int val = 0; //variable for sensor value
  5.  
  6. void setup() {
  7. Serial.begin(9600); //initialize serial communication
  8. //analogMode(analogPin, INPUT);
  9. pinMode(ledPin, OUTPUT);
  10. }
  11.  
  12. void loop() {
  13. val = analogRead(analogPin); //reading analog value
  14.  
  15. //use small delay between analogRead function for diff sensors
  16. //allow the ADC a moment to catch up
  17. delay(10);
  18.  
  19. Serial.print("flex sensor: ");
  20. Serial.println(val); //print to serial monitor
  21.  
  22. analogWrite(ledPin, val / 4);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement