Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sefloat sensorValue = 0; // variable for sensor value
- float sensorPin = A0; // variable for sensor pin
- int greenLedPin = 10;
- int yellowLedPin = 9;
- void setup() {
- pinMode(sensorPin, INPUT);
- Serial.begin(9600);
- pinMode(greenLedPin, OUTPUT);
- pinMode(yellowLedPin, OUTPUT);
- }
- void loop() {
- sensorValue = analogRead(sensorPin);
- sensorValue = (sensorValue/1023)*255;
- Serial.println(sensorValue); // print out sensorValue to the Serial Monitor
- delay(20); // delay for 0.2 seconds
- analogWrite(greenLedPin, sensorValue);
- analogWrite(yellowLedPin, sensorValue);
- int val = analogRead(0);
- val = map(val, 0, 1023, 0, 255);
- analogWrite(greenLedPin, val);
- int val2 = analogRead(0);
- val2 = map(val2, 0, 1023, 255, 0);
- analogWrite(yellowLedPin, val2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement