विषय-सूची
Processing GuI से Button बनाकर led control करें
सभी step सही से follow करें में इस page को जल्दी में बना रहा हूँ कोई गलती हो तो comment में बताएं वैसे project to work कर रहा है पर language में problem हो सकती है project facebook,whatsapp पर share जरूर करें
(adsbygoogle = window.adsbygoogle || []).push({});
Circuit बनाएं Arduino और leds से
- led1 की long pin connect करें Arduino की digital pin 12 से
- Led1 short pin connect करें Arduino की Gnd pin से
- Led2 long pin connect करें Arduino digital pin 13 से
- Led2 short pin connect करें Arduino Gnd pin से
Control & theory Arduino+Processing GUI
पहली Led keyboard पर A press करने पर on और B key press करने पर off हो जाएगी दूसरी Led keyboard पर C press करने पर on और D key press करने पर off हो जाएगी
Arduino led programming
Arduino ide को launch करें और इस program को Arduino board में upload करें
Program Arduino में कैसे upload करते है ?
G
Mechanic37
GUI1-Leds control
www.mechanic37.com
*/
int pin1=13;
int pin2=12;
void setup() {
Serial.begin(9600); // Initialize Serial Communitication
pinMode (13,OUTPUT); // Optional for Led Headlights, Reverse Lights, Etc.
pinMode(12,OUTPUT);
}
void loop() {
if (Serial.available() > 0) //Listen for signal in the serial port
{
int data = Serial.read();
switch (data) { // Switch-case of the signals in the serial port
case ‘1’: // Case Number 1 is received,
digitalWrite(13,HIGH);
break;
case ‘2’ : //// Case Number 2 is received,
digitalWrite(13,LOW);
break;
case ‘3’ : // Case Number 3 is received,
digitalWrite(12,HIGH);
break;
case ‘4’ : // Case Number 4 is received,
digitalWrite(12,LOW);
break;
case ‘5’: // Case Number 5 is received,
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
default : break;
}
}
}
(adsbygoogle = window.adsbygoogle || []).push({});
Processing में Button बनाएं Graphical User Interface (GUI) के लिये
Processing launch करें और नीचे दिया program यह से copy करके processing में paste करें
जब आप नीचे दिए program को play करेंगे तो ऐसी window create होगी जिस पर चार button है A,B,C,D keys press करने पर led on off होंगी graphical user interface create करने के लिए इसे processing software में paste करें और play button पर click करें
/*Graphical User Interface by Mechanic37
GUI1-Leds control
www.mechanic37.com
*/
import processing.serial.*; //Importing the Serial library.
Serial myPort;
int r,g,b; // initializing colours.
String M1= “ON”;
String M2= “OFF”;
String M3= “ON”;
String M4= “OFF”;
String M5= “MECHANIC37 GUI”;
void setup()
{
size(500,500);
r = 0;
g = 0;
b = 0;
println(Serial.list());
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600); // Initializing the serial port.
}
void draw()
{
background(#CC6699);
fill (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);
fill (255);
text(“LED1-A,B”,200,145);
text(“LED2-C,D”,200,295);
textSize (30);
fill (#216C09);
text(M1, 140, 200);
text(M2, 285, 200);
text(M3, 140, 350);
text(M4, 285, 350);
fill(#279B61);
text(M5, 100, 100);
}
void keyPressed()
{
switch (keyCode) {
case ‘A’:
myPort.write(‘1’);
fill(255,0,0);
rect(100,150,100,75,5);
break;
case ‘B’:
myPort.write(‘2’);
fill(255,0,0);
rect(250,150,100,75,5);
break;
case ‘C’:
myPort.write(‘3’);
fill(255,0,0);
rect(100,300,100,75,5);
break;
case ‘D’:
myPort.write(‘4’);
fill(255,0,0);
rect(250,300,100,75,5);
break;
default:
break;
}
}
(adsbygoogle = window.adsbygoogle || []).push({});
प्रातिक्रिया दे