Test for making Arduino control panel
04 Mar 2016 13:08 #71024
by finemeca
Test for making Arduino control panel was created by finemeca
Hello,
I am making a control panel with buttons connected to an Arduino
I looked at this site : ckcnc.wordpress.com/2011/01/08/simple-emc-arduino-howto/
To try, I made a hall for connection "test"
On the Arduino, I have a button that send to the serial port the letter a
Another button sending the letter b
In the Arduino serial port, the value is sent
In my hallmeter pine arduino.test does not change?
My sketch Arduino
My python script
My custompostgui.hal
I am making a control panel with buttons connected to an Arduino
I looked at this site : ckcnc.wordpress.com/2011/01/08/simple-emc-arduino-howto/
To try, I made a hall for connection "test"
On the Arduino, I have a button that send to the serial port the letter a
Another button sending the letter b
In the Arduino serial port, the value is sent
In my hallmeter pine arduino.test does not change?
My sketch Arduino
const int BoutonOn = 2; //le bouton est connecté à la broche 2 de la carte Adruino
const int BoutonOff = 3; //le bouton est connecté à la broche 3 de la carte Adruino
const int LedOn = 13; //la LED à la broche 13
int etatBoutonOn; //variable qui enregistre l'état du bouton
int etatBoutonOff; //variable qui enregistre l'état du bouton
boolean Marche;
void setup()
{
pinMode(LedOn, OUTPUT); //la led est une sortie
pinMode(BoutonOn, INPUT); //le bouton est une entrée
digitalWrite(BoutonOn,HIGH); // active pull-up interne
pinMode(BoutonOff, INPUT); //le bouton est une entrée
digitalWrite(BoutonOff,HIGH); // active pull-up interne
etatBoutonOn = LOW;
etatBoutonOff = LOW;
Marche = false;
digitalWrite(LedOn,LOW);
Serial.begin(9600);
}
void loop()
{
etatBoutonOn = digitalRead(BoutonOn);
etatBoutonOff = digitalRead(BoutonOff);
if(etatBoutonOn == HIGH)//test si le bouton a un niveau logique bas
{
delay (200) ; // ne pas relire tout de suite l'état, protection anti-rebond
Marche = true;
}
if(etatBoutonOff == HIGH) //est si le bouton a un niveau logique bas
{
delay (200) ; // ne pas relire tout de suite l'état, protection anti-rebond
Marche = false;
}
if (Marche == true)
{
digitalWrite(LedOn,HIGH); //la LED est allumée
Serial.println("a");
}
else
{
digitalWrite(LedOn,LOW); //le bouton est appuyé, la LED reste éteinte
Serial.println("b");
}
}
My python script
#!/usr/bin/python
import serial
import hal
import sys
import time
PORT = "/dev/ttyACM0"
ser = serial.Serial(PORT, 9600, timeout=2)
#Now we create the HAL component and its pins
c = hal.component("arduino")
c.newpin("test",hal.HAL_BIT,hal.HAL_IN)
c.ready()
try:
while 1:
time.sleep(1)
while ser.inWaiting():
key = ser.readline()
if(key == "a"):
c['test'] = 1
if(key == "b"):
c['test'] = 0
except KeyboardInterrupt:
# ser.write("-P;");
raise SystemExit
My custompostgui.hal
# Inclure vos commandes HAL personnalisées ici
# Les commandes contenues dans ce fichier seront lancées après quel'interface graphique AXIS (PyVCP inclus) aura démarré.
sets spindle-at-speed true
#First we load the Python user module named /user/bin/simple_arduino with the name 'arduino'
loadusr -Wn arduino Nouveau
#Map the machine on/off state to the arduino
net test arduino.test
Please Log in or Create an account to join the conversation.
04 Mar 2016 15:48 #71040
by andypugh
Replied by andypugh on topic Test for making Arduino control panel
Have you seen emergent.unpythonic.net/01198594294 ?
The link you posted is possibly a bit outdated. (2011)
The link you posted is possibly a bit outdated. (2011)
Please Log in or Create an account to join the conversation.
04 Mar 2016 15:57 - 04 Mar 2016 15:58 #71043
by finemeca
Replied by finemeca on topic Test for making Arduino control panel
Hello Andy,
I saw but I try to understand the system with a simple code.
I do not understand why it does not work?
I saw but I try to understand the system with a simple code.
I do not understand why it does not work?
Last edit: 04 Mar 2016 15:58 by finemeca.
Please Log in or Create an account to join the conversation.
Time to create page: 0.089 seconds