-
Notifications
You must be signed in to change notification settings - Fork 26
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
6 changed files
with
649 additions
and
1 deletion.
There are no files selected for viewing
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
48 changes: 48 additions & 0 deletions
48
masterclass/arduino/pot_radar_ultrasound/pot_radar_ultrasound.ino
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,48 @@ | ||
|
||
|
||
// POT INPUT | ||
int potPin = A0; | ||
int potVal = 0; | ||
|
||
// RADAR | ||
int radarPin = 2; | ||
int radarState = LOW; | ||
int radarVal = 0; | ||
|
||
// ULTRASONIC | ||
int trigPin = 9; | ||
int echoPin = 10; | ||
float duration, dist; | ||
|
||
void setup() | ||
{ | ||
pinMode(radarPin, INPUT); | ||
pinMode(trigPin, OUTPUT); | ||
pinMode(echoPin, INPUT); | ||
Serial.begin(9600); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
potVal = analogRead(potPin); // read the potentiometer value at the input pin | ||
radarVal = digitalRead(radarPin); | ||
|
||
digitalWrite(trigPin, LOW); | ||
delayMicroseconds(2); | ||
digitalWrite(trigPin, HIGH); | ||
delayMicroseconds(10); | ||
digitalWrite(trigPin, LOW); | ||
|
||
duration = pulseIn(echoPin, HIGH); | ||
dist = (duration*.0343)/2; | ||
|
||
Serial.print(potVal); | ||
Serial.print(" "); | ||
Serial.print(radarVal); | ||
Serial.print(" "); | ||
Serial.print(dist); | ||
Serial.println(); | ||
|
||
delay(50); | ||
} |
42 changes: 42 additions & 0 deletions
42
masterclass/arduino/velostat_matrix_6x6/velostat_matrix_6x6.ino
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,42 @@ | ||
|
||
#define numRows 6 | ||
#define numCols 6 | ||
#define sensorPoints numRows*numCols | ||
|
||
int rows[] = {A0,A1,A2,A3,4,5}; | ||
int cols[] = {2,3,4,5,6,7}; | ||
int incomingValues[sensorPoints] = {}; | ||
|
||
void setup() { | ||
// set all rows and columns to INPUT (high impedance): | ||
for (int i = 0; i < numRows; i++) { | ||
pinMode(rows[i], INPUT_PULLUP); | ||
} | ||
for (int i = 0; i < numCols; i++) { | ||
pinMode(cols[i], INPUT); | ||
} | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() { | ||
for (int colCount = 0; colCount < numCols; colCount++) { | ||
|
||
pinMode(cols[colCount], OUTPUT); // set as OUTPUT | ||
digitalWrite(cols[colCount], LOW); // set LOW | ||
for (int rowCount = 0; rowCount < numRows; rowCount++) { | ||
|
||
incomingValues[colCount * numRows + rowCount] = analogRead(rows[rowCount]); // read INPUT | ||
}// end rowCount | ||
|
||
pinMode(cols[colCount], INPUT); // set back to INPUT! | ||
}// end colCount | ||
|
||
// Print the incoming values of the grid: | ||
for (int i = 0; i < sensorPoints; i++) { | ||
Serial.print(incomingValues[i]); | ||
if (i < sensorPoints - 1) | ||
Serial.print(" "); | ||
} | ||
Serial.println(); | ||
delay(10); | ||
} |
Oops, something went wrong.