Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int analogInPin = A1;
- int sensorValue = 0; // value read from the pot
- int outputValue = 0;
- void setup() {
- // initialize both serial ports:
- Serial.begin(57600);
- pinMode(13, OUTPUT);
- digitalWrite(13, HIGH);
- }
- void loop() {
- // read the analog in value:
- if (Serial.available()) {
- char inByte = Serial.read();
- if (inByte == 'D') {
- sensorValue = analogRead(analogInPin);
- // map it to the range of the analog out:
- outputValue = map(sensorValue, 0, 1023, 0, 255);
- // change the analog out value:
- Serial.write(outputValue);
- }
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement