Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // Michael Montella
  2. // Lab 4
  3.  
  4. int pot = A0;
  5. int bendSensor = A1;
  6. int val = 0; // variable for sensor value
  7. int val2 = 0;
  8.  
  9. void setup() {
  10. Serial.begin(9600); // initialize serial communication
  11.  
  12. }
  13.  
  14. void loop() {
  15. val = analogRead(pot); // reading analog value
  16.  
  17. // Use a small delay between analogRead functions for different sensors
  18. // Allows the ADC to catch up
  19.  
  20. delay(10);
  21. val2 = analogRead(bendSensor);
  22.  
  23. analogWrite(9, val/4);
  24. analogWrite(10, map(val2, 0, 10, 0, 255));
  25.  
  26. Serial.println(val2); // print serial number
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement