Browse Source

„TactiloControllerPanda.ino“ ändern

master
Tobias Baumann 2 years ago
parent
commit
de177ed33f
1 changed files with 84 additions and 77 deletions
  1. 84
    77
      TactiloControllerPanda.ino

+ 84
- 77
TactiloControllerPanda.ino View File

@@ -23,100 +23,107 @@

void setup()
{
//init serial
Serial.begin(115200);
//init serial
Serial.begin(115200);
//init GPIOs
Serial.println("...init GPIOs");
set_PinMode();
set_AllLow();
//init GPIOs
Serial.println("...init GPIOs");
set_PinMode();
set_AllLow();
}

void loop()
{
char SerialData;
char SerialData;

if(Serial.available() > 0)
{
SerialData = Serial.read();
}
if(Serial.available() > 0)
{
SerialData = Serial.read();
}

processSerialData(SerialData);
processSerialData(SerialData);
}

void set_PinMode()
{
//set all pins to OUTPUT
pinMode(TAC1, OUTPUT);
pinMode(TAC2, OUTPUT);
pinMode(TAC3, OUTPUT);
pinMode(TAC4, OUTPUT);
pinMode(TAC5, OUTPUT);
pinMode(TAC6, OUTPUT);
pinMode(LED, OUTPUT);
//set all pins to OUTPUT
pinMode(TAC1, OUTPUT);
pinMode(TAC2, OUTPUT);
pinMode(TAC3, OUTPUT);
pinMode(TAC4, OUTPUT);
pinMode(TAC5, OUTPUT);
pinMode(TAC6, OUTPUT);
pinMode(LED, OUTPUT);
}

void set_AllLow()
{
//set all pins to LOW
digitalWrite(TAC1, LOW);
digitalWrite(TAC2, LOW);
digitalWrite(TAC3, LOW);
digitalWrite(TAC4, LOW);
digitalWrite(TAC5, LOW);
digitalWrite(TAC6, LOW);
digitalWrite(LED, LOW);
//set all pins to LOW
digitalWrite(TAC1, LOW);
digitalWrite(TAC2, LOW);
digitalWrite(TAC3, LOW);
digitalWrite(TAC4, LOW);
digitalWrite(TAC5, LOW);
digitalWrite(TAC6, LOW);
digitalWrite(LED, LOW);
}

void processSerialData(char SerialData)
{
switch(SerialData)
{
case '0':
if(digitalRead(LED) == LOW)
{
digitalWrite(LED, HIGH);
Serial.println("...Start Tactile Session");
}
else
{
set_AllLow();
Serial.println("...End Tactile Session");
}
break;
case '1':
digitalWrite(TAC1, !digitalRead(TAC1));
Serial.print("Tactilo 1: ");
Serial.println(digitalRead(TAC1));
break;
case '2':
digitalWrite(TAC2, !digitalRead(TAC2));
Serial.print("Tactilo 2: ");
Serial.println(digitalRead(TAC2));
break;
case '3':
digitalWrite(TAC3, !digitalRead(TAC3));
Serial.print("Tactilo 3: ");
Serial.println(digitalRead(TAC3));
break;
case '4':
digitalWrite(TAC4, !digitalRead(TAC4));
Serial.print("Tactilo 4: ");
Serial.println(digitalRead(TAC4));
break;
case '5':
digitalWrite(TAC5, !digitalRead(TAC5));
Serial.print("Tactilo 5: ");
Serial.println(digitalRead(TAC5));
break;
case '6':
digitalWrite(TAC6, !digitalRead(TAC6));
Serial.print("Tactilo 6: ");
Serial.println(digitalRead(TAC6));
break;
default:
break;
}
switch(SerialData)
{
case '0':
if(digitalRead(LED) == LOW)
{
digitalWrite(LED, HIGH);
Serial.println("...Start Tactile Session");
}
else
{
set_AllLow();
Serial.println("...End Tactile Session");
}
break;

case '1':
digitalWrite(TAC1, !digitalRead(TAC1));
Serial.print("Tactilo 1: ");
Serial.println(digitalRead(TAC1));
break;

case '2':
digitalWrite(TAC2, !digitalRead(TAC2));
Serial.print("Tactilo 2: ");
Serial.println(digitalRead(TAC2));
break;

case '3':
digitalWrite(TAC3, !digitalRead(TAC3));
Serial.print("Tactilo 3: ");
Serial.println(digitalRead(TAC3));
break;

case '4':
digitalWrite(TAC4, !digitalRead(TAC4));
Serial.print("Tactilo 4: ");
Serial.println(digitalRead(TAC4));
break;
case '5':

digitalWrite(TAC5, !digitalRead(TAC5));
Serial.print("Tactilo 5: ");
Serial.println(digitalRead(TAC5));
break;

case '6':
digitalWrite(TAC6, !digitalRead(TAC6));
Serial.print("Tactilo 6: ");
Serial.println(digitalRead(TAC6));
break;

default:
break;
}
}

Loading…
Cancel
Save