5 bit binary led blinking using serial communication between 2 arduinos

Hi , I’ve got a project where I want to light up 5 leds according to the input given from the first arduino (serial monitor).
Through serial communication, the 5leds which is to be connected to the 2nd arduino as outputs should blink based on the 5 bit binary number given.
Hoping for your response
Thank you

We can't see your code

Please follow the advice on posting code given in Read this before posting a programming question

Note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

If the code exceeds the 9000 character inline limit then attach it to a post

That’s because I haven’t written it ..I don’t know how to begin
I wanted a sample code for this so that i can do the connections related to the code in tinkercad

Start simple. Do you know how to set an output, HIGH or LOW ?

Have you looked at the examples in the IDE ?

Is the project your idea or have you been asked/told to do it by someone else ?

Yeah I know the basics ..
Well actually both , I know how to do it in case of 1 led , where if I give inputs as 1 and 0 the led will blink and turn off but
The task which was given to me was for 5 leds and 5 bit binary input

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.

This may help, its a very good tutorial on serial comms with examples;
https://forum.arduino.cc/index.php?topic=396450.0

Tom... :slight_smile:

The task which was given to me was for 5 leds and 5 bit binary input

Let's start with the inputs. How will the user be expected to enter the bits to indicate that that an associated LED should blink ?

So first we write a statement asking the user to enter the binary input , which will appear in the serial monitor

siddharth513:
So first we write a statement asking the user to enter the binary input , which will appear in the serial monitor

Yes, but what do you want them to enter ?

For 5 bits maybe they enter 10010 or maybe 1,0,0,1,0 or maybe
1
0
0
1
0

or maybe 18 in decimal or even 12 in Hex

Is what they enter in low to high bit order or high to low bit order ?

It is vital to know what to expect. Do your assignment instructions tell you ?

Nothing was mentioned, it was told that the input should be a 5 bit binary so I’m assuming something like 10010

Before all that I’ll say what I know
So we have to use array in this since it will be easier to handle the states . In the setup we start with serial.begin()
Then in the loop we use for loop to write maybe something like serial.write( val*)*
Then for the second arduino, we setup the pin modes of the leds and in the loop ,
Start with if ( serial.available()>o) and in a for loop , use serial.read() and finally digitalwrite them..
Am I on the right track or is it completely wrong?

siddharth513:
Hi , I’ve got a project where I want to light up 5 leds according to the input given from the first arduino (serial monitor).
Through serial communication, the 5leds which is to be connected to the 2nd arduino as outputs should blink based on the 5 bit binary number given.
Hoping for your response
Thank you

How are the two Arduinos connected? If you're entering numbers into the first Arduino, its only serial port will be in use. So there isn't one left over to communicate with the second Arduino.

Usually, a project like this requires using code or at least approaches that you've already learned and implemented in previous assignments.

It’s uart .. the rx of one is connected to the TX of the other and vice versa. That’s how the 2 arduinos are connected and the common ground

Which Arduino boards are you using ?

I’m using arduino uno

The Uno only has one UART, and that is used by the Serial monitor

Time for a new plan, maybe using SoftwareSerial to create the interface between the boards

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.