Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
06 Serial Comm and Processing/programs/arduino + processing/process_input/process_input.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//Program by Jeremy Blum | ||
//www.jeremyblum.com | ||
//Uses pot data from arduino to draw stuff | ||
|
||
import processing.serial.*; | ||
Serial port; | ||
float brightness = 0; | ||
|
||
void setup() | ||
{ | ||
size(500,500); | ||
port = new Serial(this, "COM3", 9600); | ||
port.bufferUntil('\n'); | ||
} | ||
|
||
void draw() | ||
{ | ||
background(0,0,brightness); | ||
} | ||
|
||
void serialEvent (Serial port) | ||
{ | ||
brightness = float(port.readStringUntil('\n')); | ||
} |
20 changes: 20 additions & 0 deletions
20
...Comm and Processing/programs/arduino + processing/read_pot_and_send/read_pot_and_send.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//Program by Jeremy Blum | ||
//www.jeremyblum.com | ||
//Send data from a POT over serial to the computer | ||
|
||
//Define Pins | ||
int potPin = 0; | ||
|
||
void setup() | ||
{ | ||
//Create Serial Object (9600 Baud) | ||
Serial.begin(9600); | ||
} | ||
|
||
void loop() | ||
{ | ||
int val = map(analogRead(potPin), 0, 1023, 0, 255); | ||
Serial.println(val); | ||
delay(50); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
06 Serial Comm and Processing/programs/keyboard_control/keyboard_control.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//Program by Jeremy Blum | ||
//www.jeremyblum.com | ||
//Uses commands from computer to control arduino | ||
|
||
int ledPin = 13; | ||
|
||
void setup() | ||
{ | ||
//Create Serial Object | ||
Serial.begin(9600); | ||
|
||
pinMode(ledPin, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
//Have the arduino wait to receive input | ||
while (Serial.available() == 0); | ||
|
||
//Read the Input | ||
int val = Serial.read() - '0'; | ||
|
||
if (val == 1) | ||
{ | ||
Serial.println("Led is On"); | ||
digitalWrite(ledPin, HIGH); | ||
} | ||
else if (val == 0) | ||
{ | ||
Serial.println("Led is Off"); | ||
digitalWrite(ledPin, LOW); | ||
} | ||
else | ||
{ | ||
Serial.println("Invalid!"); | ||
} | ||
Serial.flush(); | ||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
06 Serial Comm and Processing/programs/keyboard_control_fail/keyboard_control_fail.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//Program by Jeremy Blum | ||
//www.jeremyblum.com | ||
//Uses commands from computer to control arduino | ||
|
||
//Define Pins | ||
int ledPin = 13; | ||
|
||
void setup() | ||
{ | ||
//Create Serial Object (9600 Baud) | ||
Serial.begin(9600); | ||
|
||
pinMode(ledPin, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
|
||
|
||
//Now we play the waiting game. | ||
while (Serial.available() == 0); | ||
|
||
//read the incoming byte | ||
int val = Serial.read(); | ||
|
||
Serial.println(val); | ||
|
||
|
||
} |