Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int val = 0; // where to store info from analog 5
- int pin11 = 11; // output of red led
- void setup() {
- pinMode(11, OUTPUT);
- }
- void loop() {
- val = analogRead(5); // reads in the values from analog 5 and
- //assigns them to val
- if(val >= 1){
- val=map(val,1,1023,1,255);
- analogWrite(pin11, val); // *note also messing with the resistor should change
- // the sensitivity
- }else{ // analogWrite(pin11, val); just tuns on the led with
- // the intensity of the variable val
- analogWrite(pin11, 0); // the else statement is just telling the microcontroller
- // to turn off the light if there is no EMF detected
- }
- }
Add Comment
Please, Sign In to add comment