Browse Source

Dateien hochladen nach „“

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

+ 77
- 77
TactiloControllerPanda.ino View File

@@ -23,101 +23,101 @@

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();
processSerialData(SerialData);
}
if(Serial.available() > 0)
{
SerialData = Serial.read();
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);
//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);
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);
//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);
digitalWrite(LED, LOW);
}

void processSerialData(char SerialData)
{
switch(SerialData)
{
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;
case 'b':
if(digitalRead(LED) == LOW)
{
digitalWrite(LED, HIGH);
Serial.println("...Begin Tactile Session");
}
break;
case 'e':
if(digitalRead(LED) == HIGH)
{
digitalWrite(LED, LOW);
Serial.println("...End Tactile Session");
}
break;
default:
break;
}
switch(SerialData)
{
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;
case 'b':
if(digitalRead(LED) == LOW)
{
digitalWrite(LED, HIGH);
Serial.println("...Begin Tactile Session");
}
break;
case 'e':
if(digitalRead(LED) == HIGH)
{
digitalWrite(LED, LOW);
Serial.println("...End Tactile Session");
}
break;
default:
break;
}
}

Loading…
Cancel
Save