Guest User

Untitled

a guest
Nov 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. int val = 0; // where to store info from analog 5
  2. int pin11 = 11; // output of red led
  3.  
  4. void setup() {
  5. pinMode(11, OUTPUT);
  6.  
  7. }
  8.  
  9. void loop() {
  10.  
  11. val = analogRead(5); // reads in the values from analog 5 and
  12. //assigns them to val
  13. if(val >= 1){
  14.  
  15. val=map(val,1,1023,1,255);
  16. analogWrite(pin11, val); // *note also messing with the resistor should change
  17. // the sensitivity
  18. }else{ // analogWrite(pin11, val); just tuns on the led with
  19. // the intensity of the variable val
  20. analogWrite(pin11, 0); // the else statement is just telling the microcontroller
  21. // to turn off the light if there is no EMF detected
  22. }
  23.  
  24.  
  25. }
Add Comment
Please, Sign In to add comment