Advertisement
roniloapin

Untitled

Mar 24th, 2017
3,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #inc
  2. lude <popx2.h>  // POP-X2 Board
  3.  
  4. const int analogOutPin = 19; // Analog output pin that the LED is attached to
  5.  
  6. int pos = 0;        // value read from the pot
  7. int outputValue = 0;        // value output to the PWM (analog out)
  8.  
  9. void setup() {
  10.   // initialize serial communications at 9600 bps:
  11.   OK();
  12.   glcdMode(3);
  13.   setTextSize(2);
  14. }
  15.  
  16. void loop() {
  17.   // read the analog in value:
  18.   pos = knob();
  19.   // map it to the range of the analog out:
  20.   outputValue = map(pos, 0, 1000, 0, 255);
  21.   // change the analog out value:
  22.   analogWrite(analogOutPin, outputValue);
  23.   // print the results to the serial monitor:
  24.   glcd(1, 2, "%d ",outputValue);
  25.  
  26.   // wait 2 milliseconds before the next loop
  27.   // for the analog-to-digital converter to settle
  28.   // after the last reading:
  29.   delay(2);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement