Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #inc
- lude <popx2.h> // POP-X2 Board
- const int analogOutPin = 19; // Analog output pin that the LED is attached to
- int pos = 0; // value read from the pot
- int outputValue = 0; // value output to the PWM (analog out)
- void setup() {
- // initialize serial communications at 9600 bps:
- OK();
- glcdMode(3);
- setTextSize(2);
- }
- void loop() {
- // read the analog in value:
- pos = knob();
- // map it to the range of the analog out:
- outputValue = map(pos, 0, 1000, 0, 255);
- // change the analog out value:
- analogWrite(analogOutPin, outputValue);
- // print the results to the serial monitor:
- glcd(1, 2, "%d ",outputValue);
- // wait 2 milliseconds before the next loop
- // for the analog-to-digital converter to settle
- // after the last reading:
- delay(2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement