Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int outPin = 8; // digital pin 8
- int analogPin = 3;
- int raw;
- int duty;
- void setup()
- {
- pinMode(outPin, OUTPUT); // sets the digital pin as output
- }
- void loop()
- {
- raw = analogRead (analogPin);
- if (raw > 1 and raw < 50) {
- duty = raw/3;
- digitalWrite(outPin, HIGH); // sets the pin on
- delayMicroseconds(duty);
- digitalWrite(outPin, LOW); // sets the pin off
- delayMicroseconds(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement