Advertisement
Guest User

Untitled

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