This is the code for the Arduino that we made in order to have an output from the Myoware muscle sensor.
const int sensorPin = A3; const int minVal = 150; const int medVal = 300; const int highVal = 600; int ledRed (9); int ledYellow (6); int ledGreen (5); int state;
void setup() { pinMode(ledRed, OUTPUT); pinMode(ledYellow, OUTPUT); pinMode(ledGreen, OUTPUT);
Serial.begin(9600); }
void loop() {
Serial.print("ValueA3_"); // signal value - input ANALOGE
Serial.print(analogRead("A3")); Serial.println();
int sensorVal = analogRead(sensorPin);
if ( sensorVal > minVal && sensorVal < medVal) { digitalWrite(ledRed, HIGH); digitalWrite(ledYellow, LOW); digitalWrite(ledGreen, LOW);// output red light light Serial.println("RED"); }
else if (sensorVal > medVal && sensorVal < highVal) { digitalWrite(ledYellow, HIGH);// YELLOW digitalWrite(ledRed, LOW); digitalWrite(ledGreen, LOW); Serial.println("YELLOW");
} else if (sensorVal > highVal)
{ digitalWrite(ledGreen, HIGH); digitalWrite(ledRed, LOW); digitalWrite(ledYellow, LOW); Serial.println("GREEN"); } //
// BLINKING LIGHTS /// else { // { // digitalWrite(ledRed, HIGH); // digitalWrite(ledYellow, HIGH); // digitalWrite(ledGreen, HIGH); // turn the LED on (HIGH is the voltage level) // delay(70); // wait for a second // digitalWrite(ledRed, LOW); // digitalWrite(ledYellow, LOW); // digitalWrite(ledGreen, LOW); // turn the LED off by making the voltage LOW // delay(70); // wait for a second // }
delay(1000); }
Comments