Menu Close
Spread the love

Arduino Visual Basic

 

3 led-output Arduino Serial Communication with Visual Basic Project.
Visual basic windows application with Arduino nano
Serial Communication 3 led output.

3 led-output Arduino

The reason for this project is to show you, how to manage Serial connections
in Visual Studio 2013 with VisualBasic as the main programming language.

Parts Required:

  1. Arduino NANO
  2. LED (3)
  3. resistor 220 ohm (3) if you want
  4. Wires to connect it all together

 

uper
int led = 9;           // the pin that the LED is attached to
int led2 = 8;
int led3 = 7;
int brightness = 0;    // how bright the LED is
int brightness2 = 0;
int brightness3 = 0;

// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
char buffer[] = {‘ ‘,‘ ‘,}; // Receive up to 7 bytes ich kann mehr von die nutzen
while (!Serial.available()); // Wait for characters
Serial.readBytesUntil(‘n’, buffer, 2);
int fadeAmount = atoi(buffer);
Serial.println(fadeAmount);

// change the brightness for next time through the loop:
brightness = 0;
brightness2 = 0;
Serial.println(brightness);
if (fadeAmount == 2){

brightness2 = 255;
brightness = 0;
brightness3 = 0;
analogWrite(led2, brightness2);
analogWrite(led, brightness );
analogWrite(led3, brightness3);
}
if (fadeAmount == 4){
brightness = 255;
brightness2 = 0;
brightness3 = 0;
analogWrite(led, brightness);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
}
if (fadeAmount == 3){

brightness3 = 255;
brightness2 = 0;
brightness = 0;
analogWrite(led, brightness);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
}
if (fadeAmount == 0){

brightness3 = 0;
brightness2 = 0;
brightness = 0;
analogWrite(led, brightness);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
}

if (fadeAmount == 5){

brightness3 = 255;
brightness2 = 255;
brightness = 255;
analogWrite(led, brightness);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
}
delay(1);

}

Down
3 led-output Arduino

For more Please make sure to subscribe to Officialhrm YouTube channel and like Facebook Page.

Thank you for visiting OfficialhrmPlease don’t forget to share this website with your friends.

Download

File Description Date added File size Downloads
zip 3 led output Serial_comminication August 15, 2018 4:54 pm 195 KB 3092
Posted in Arduino

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *