Stap 4: Stap 4-verwerking programmering voor GUI
/ * Grafische gebruikersinterface door Mechanic37
GUI1-Leds bepalen www.mechanic37.com * /
importeren van processing.serial.*;
Seriële myPort;
int r, g, b;
String M1 = "30D";
String M2 = "60D";
String M3 = "90D";
M4 string = "180D";
M5 string = "MECHANIC37 GUI";
VOID Setup {}
size(500,500);
r = 0; g = 0; b = 0;
println(Serial.List());
String portName = Serial.list() [0];
myPort = nieuwe Serial (deze, portName, 9600); }
VOID draw() {}
Background(255);
vullen (255,255,255);
Fill(#279B61);
rect(90,125,300,130,20);
Fill(255);
rect(115,150,100,75,5);
rect(265,150,100,75,5);
Fill(#279B61);
rect(90,275,300,130,20);
Fill(255);
rect(115,300,100,75,5);
rect(265,300,100,75,5);
textSize(20);
vullen (255);
Text("Press-A",130,145);
Text("Press-B",280,145);
Text("Press-C",130,295);
Text("Press-D",280,295);
textSize (30);
vulling (#216C 09);
tekst (M1, 140, 200);
tekst (M2, 285, 200);
tekst (M3, 140, 350);
tekst (M4, 279, 350);
Fill(#279B61);
tekst (M5, 100, 100);
}
ongeldig keyPressed() {}
schakelaar (keyCode) {}
Case "A":
myPort.write('1');
Fill(255,0,0);
rect(100,150,100,75,5);
breken;
Case "B":
myPort.write('2');
Fill(255,0,0);
rect(250,150,100,75,5);
breken;
Case "C":
myPort.write('3');
Fill(255,0,0);
rect(100,300,100,75,5);
breken; geval zou ':
myPort.write('4');
Fill(255,0,0);
rect(250,300,100,75,5);
breken;
standaard:
breken;
} }
Bezoek myblog-mechanic37.com