Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. int pot = 0; //potentiometer variable
  2. //adding for a photoresistor
  3. int pressure = 0;
  4. void setup() {
  5. // put your setup code here, to run once:
  6. Serial.begin(9600); // initialize serial
  7. }
  8.  
  9. void loop() {
  10. // put your main code here, to run repeatedly:
  11. pot = analogRead(A0);
  12. pressure = analogRead(A1);
  13. Serial.println(pot);
  14. Serial.print(" pressure ");
  15. Serial.println(pressure);
  16. int lightVals = map(pot, 0, 1023, 0, 255);
  17. int light2Vals = map(pressure, 0, 1007, 0, 255);
  18. analogWrite(10, lightVals);
  19. analogWrite(9, light2Vals);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement