Created
November 1, 2018 23:20
-
-
Save natendaben/5524bc2105624b0439dfc0d88eafb2c6 to your computer and use it in GitHub Desktop.
Lab 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pot = 0; | |
int pot2 = 0; | |
int incoming; //variable for storing incoming data | |
void setup() { | |
Serial.begin(9600); | |
pinMode(2, OUTPUT); | |
} | |
void loop() { | |
pot = analogRead(A0); | |
pot2 = analogRead(A1); | |
//send ASCII | |
Serial.print(pot); | |
Serial.print(","); | |
Serial.println(pot2); | |
//receive serial from p5 | |
if(Serial.available() > 0) | |
{ | |
incoming = Serial.read(); | |
if(incoming =='A') | |
{ | |
tone(2,294, 50); | |
} | |
if(incoming == 'B') | |
{ | |
tone(2,386, 50); | |
} | |
if(incoming == 'C') | |
{ | |
tone(2,330, 50); | |
} | |
if(incoming == 'D') | |
{ | |
tone(2,345, 50); | |
} | |
if(incoming == 'E') | |
{ | |
tone(2,261, 50); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment