Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Jung Min Yean
- * 03/28/19
- * Learning How to Use Analog Read and Write
- */
- const int LedPin1 = 9;
- const int LedPin2 = 10;
- const int LedPin3 = 11;
- const int PotPin = A0;
- int PotVal = 0;
- void setup()
- {
- pinMode(LedPin1, OUTPUT);
- pinMode(LedPin2, OUTPUT);
- pinMode(LedPin3, OUTPUT);
- pinMode(PotPin, INPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- // test potentiometer
- PotVal = analogRead(PotPin);
- Serial.println(PotVal);
- PotVal = PotVal/4;
- analogWrite(LedPin1, PotVal);
- analogWrite(LedPin2, PotVal);
- analogWrite(LedPin3, PotVal);
- }
Add Comment
Please, Sign In to add comment