Advertisement
Guest User

Untitled

a guest
Feb 17th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. const int analogInPin = A1;
  2. int sensorValue = 0; // value read from the pot
  3. int outputValue = 0;
  4. void setup() {
  5. // initialize both serial ports:
  6. Serial.begin(57600);
  7. pinMode(13, OUTPUT);
  8. digitalWrite(13, HIGH);
  9. }
  10.  
  11. void loop() {
  12. // read the analog in value:
  13. if (Serial.available()) {
  14. char inByte = Serial.read();
  15. if (inByte == 'D') {
  16. sensorValue = analogRead(analogInPin);
  17. // map it to the range of the analog out:
  18. outputValue = map(sensorValue, 0, 1023, 0, 255);
  19. // change the analog out value:
  20. Serial.write(outputValue);
  21. }
  22. }
  23. delay(100);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement