Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Importar biblioteca comunicacao serie
- import processing.serial.*;
- // Criar objeto do tipo Serial chamado myPort
- Serial myPort;
- // Definir variaveis que mudam as cores dos botoes
- int v01 = 150;
- int v01c = 150;
- int v02 = 150;
- int v02c = 150;
- int v03 = 150;
- int v03c = 150;
- int v04 = 150;
- int v04c = 150;
- int v05 = 150;
- int v05c = 150;
- PImage img;
- void setup() {
- // Abrir o porto de comunicação
- myPort = new Serial(this, Serial.list()[0], 9600);
- // Criar uma janela com as dimensões 460x230 e preencher a preto
- //size(460, 230);
- size(900,712);
- surface.setResizable(true);
- img = loadImage("teste.png");
- // Nome da interface a letras brancas no fundo da janela
- textSize(24);
- textAlign(CENTER);
- fill(255, 255, 255);
- text("Bruno M.", 230, 210);
- // fullScreen();
- }
- void draw() {
- background(img);
- // VAGA 01
- fill(0, v01, 0);
- rect(53, 0, 140, 220);
- fill(255, 255, 255);
- textSize(24);
- textAlign(CENTER);
- text("01", 90, 95);
- // VAGA 02
- fill(v02, 0, 0);
- rect(225, 0, 140, 220);
- fill(255,255,255);
- text("02", 250, 95);
- // VAGA 03
- fill(0, v03, 0);
- rect(395,0,140,220);
- fill(255,255,255);
- text("03",450,95);
- // VAGA 04
- fill(0, v04, 0);
- rect(560,0,140,220);
- fill(255,255,255);
- text("04",590,95);
- // VAGA 05
- fill(0,v04,0);
- rect(730, 0, 140, 220);
- fill(255,255,255);
- text("05", 760, 95);
- // Enviar informacao para o Arduino
- // Premir botao verde
- if (mousePressed && mouseX > 20 && mouseX < 160 && mouseY > 20 && mouseY < 160)
- {
- // Desligar LED verde
- if (v01 == 255)
- {
- myPort.write("2");
- }
- // Ligar LED verde
- else
- {
- myPort.write("1");
- }
- }
- // Premir botao vermelho
- else if (mousePressed && mouseX > 160 && mouseX < 300 && mouseY > 20 && mouseY < 160)
- {
- // Desligar LED vermelho
- if (v02 == 255 && v02c == 255)
- {
- myPort.write("4");
- }
- // Ligar LED vermelho
- else
- {
- myPort.write("3");
- }
- }
- }
- void mouseClicked() {
- // Botao verde
- if (mouseX > 20 && mouseX < 160 && mouseY > 20 && mouseY < 160)
- {
- if (v01 == 150)
- {
- v01c = 255;
- }
- else
- {
- v01 = 150;
- }
- }
- // Botao vermelho
- if (mouseX > 160 && mouseX < 300 && mouseY > 20 && mouseY < 160)
- {
- if (v02 == 150 && v02 == 150)
- {
- v02c = 255;
- v02c = 255;
- }
- else
- {
- v01 = 150;
- v01 = 150;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement