In this Project, You'll make your own GUI and .EXE file for computer to control the LEDs using Arduino and Processing.
Circuit Diagram:
Arduino & Processing Code:
arduino_code.ino
//This Code is Developed by Sdev //Follow Us Here : https://youtube.com/sdevelectronics #define led1 4 //red #define led2 3 //green #define led3 2 //blue void setup() { Serial.begin(9600); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); } void loop() { if (Serial.available()) { char val = Serial.read(); if (val == 'R') { digitalWrite(led1, HIGH); } if (val == 'r') { digitalWrite(led1, LOW); } if (val == 'G') { digitalWrite(led2, HIGH); } if (val == 'g') { digitalWrite(led2, LOW); } if (val == 'B') { digitalWrite(led3, HIGH); } if (val == 'b') { digitalWrite(led3, LOW); } } }
processing_code.pde
//This Code is Developed by Sdev //Follow Us Here : https://youtube.com/sdevelectronics import controlP5.*; //import ControlP5 library import processing.serial.*; Serial port; ControlP5 cp5; //create ControlP5 object PFont font; void setup() { size(480, 360); //window size, (width, height) port = new Serial(this, "COM5", 9600); //Change Your COM Port Here cp5 = new ControlP5(this); font = createFont("calibri light bold", 20); //Custom Font cp5.addButton("red_on") //Name of the Button .setPosition(40, 60) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(255, 0, 0)) ; cp5.addButton("red_off") //Name of the Button .setPosition(260, 60) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(255, 0, 0)) ; cp5.addButton("green_on") //Name of the Button .setPosition(40, 160) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(0, 255, 0)) ; cp5.addButton("green_off") //Name of the Button .setPosition(260, 160) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(0, 255, 0)) ; cp5.addButton("blue_on") //Name of the Button .setPosition(40, 260) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(0, 0, 255)) ; cp5.addButton("blue_off") //Name of the Button .setPosition(260, 260) //(x,y) top left Corner .setSize(180, 60) //(width, height) .setFont(font) .setColorBackground(color(0, 0, 255)) ; } void draw() { background(50, 50, 50); //background color of window (r, g, b) //Title fill(255, 255, 255); //text color (r, g, b) textFont(font); text("Simple LED Control", 150, 30); //("text", x, y) } void red_on() { port.write('R'); } void green_on() { port.write('G'); } void blue_on() { port.write('B'); } void red_off() { port.write('r'); } void green_off() { port.write('g'); } void blue_off() { port.write('b'); }
Software Used:
1. Processing - https://processing.org/download/
Youtube Video Tutorial:
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
No comments:
Post a Comment