Created
April 30, 2013 14:30
-
-
Save maditnerd/5489106 to your computer and use it in GitHub Desktop.
Envoi massif de codes 433.92Mhz Auteur: Sarrailh Rémi (maditnerd) License : Gplv3 Description: Ce code permet d'envoyer séquentiellement les codes présent dans codes.txt au port série d'un arduino Arduino: Ce code nécessite de programmer l'Arduino avec ce code https://gist.github.com/maditnerd/5489092
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Envoi massif de codes 433.92Mhz | |
Auteur: Sarrailh Rémi (maditnerd) | |
License : Gplv3 | |
Description: | |
Ce code permet d'envoyer séquentiellement les codes | |
présent dans codes.txt | |
Arduino: | |
Ce code nécessite de programmer l'Arduino avec ce code | |
https://gist.github.com/maditnerd/5489092 | |
*/ | |
import processing.serial.*; //Bibliothèque de communication en série | |
PFont police; //Police d'écriture | |
Serial Serial_arduino; // Connexion au port série | |
int nbcode = 0; | |
int variable = 20; | |
String[] liste_code; | |
void setup() { | |
//On connecte au démarrage l'arduino avec l'ordinateur (On part du principe que l'arduino sera sur le dernière port série connecté) | |
Serial_arduino = new Serial(this, Serial.list()[Serial.list().length-1], 9600); | |
size(420, 130); | |
smooth(); | |
//Création de la police d'écriture | |
police = createFont("Arial", 19, true); | |
textFont(police); | |
//Aligne le texte au centre | |
textAlign(CENTER); | |
int variable = 10; | |
//Ouverture du fichier des codes | |
liste_code = loadStrings("codes.txt"); | |
if (liste_code == null) | |
{ | |
background(255, 0, 0); | |
//Titre | |
fill(0); | |
text("codes.txt introuvable!", width/2, 20); | |
line(10, 30, 400, 30); | |
} | |
else | |
{ | |
//Création de l'interface | |
//Titre | |
fill(0); | |
text("Commandes LED DIMMER", width/2, 20); | |
line(10, 30, 400, 30); | |
//Boite ON | |
fill(255); | |
rect(10, 40, 40, 40); | |
fill(255, 0, 0); | |
text("0N", 30, 65); | |
//Boite OFF | |
fill(255); | |
rect(80, 40, 40, 40); | |
fill(255, 0, 0); | |
text("0FF", 100, 65); | |
//Boite + DIMMER | |
fill(255); | |
rect(160, 40, 80, 40); | |
fill(255, 0, 0); | |
text("UP", 200, 65); | |
//Boite - DIMMER | |
fill(255); | |
rect(240, 40, 80, 40); | |
fill(255, 0, 0); | |
text("DOWN", 280, 65); | |
} | |
} | |
void draw() | |
{ | |
} | |
void mouseReleased() | |
{ | |
if (mouseY > 40 && mouseY < 80) | |
{ | |
//ON BUTTON | |
if (mouseX > 10 && mouseX < 50) | |
{ | |
for (int i = 0; i < liste_code.length; i ++ ) | |
{ | |
Serial_arduino.write(liste_code[i]); | |
println(liste_code[i]); | |
delay(30); | |
} | |
} | |
//A FAIRE | |
//OFF BUTTON | |
if (mouseX > 80 && mouseX < 120) | |
{ | |
} | |
//UP BUTTON | |
if (mouseX > 160 && mouseX < 240) | |
{ | |
} | |
//DOWN BUTTON | |
if (mouseX > 240 && mouseX < 280) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment