Beruflich Dokumente
Kultur Dokumente
// script. Upload this sketch on to the arduino first then run the python
// script. Always close serial monitor/plotter before running python script
// as both cannot be run simultaneously.
// VARIABLE DECLARATION
const int pushButton = A3; // Button is connected to analog pin #A5
const int xInput = A0; // X-Axis Analog Pin Input (A0)
const int yInput = A2; // Y-Axis Analog Pin Input (A1)
const int zInput = A1; // Z-Axis Analog Pin Input (A2)
const int sampleSize = 20;
int xRaw, yRaw, zRaw, xScaled, yScaled, zScaled, button;
int count = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
// Read raw values.
xRaw = analogRead(xInput);
yRaw = analogRead(yInput);
zRaw = analogRead(zInput);
// BUTTON
button = analogRead(pushButton);
if (button == 0) {
while (button == 0) {
button = analogRead(pushButton);
}
if (button > 0) {
button = analogRead(pushButton);
Serial.println('H');
}
button = analogRead(pushButton);
}