[vc_row][vc_column][vc_column_text]It is great for you that you could light and put out a LED light!
Next we will learn light the 8 LED lamp at the same time, meanwhile we will test the pcDuino through the different light order。
This tutorial will help you do this experiment and have a deep understand of pcDuino.
You will know the programming skills of how to make the code clearly and neat through the LED lamp the experiment.
For () loops : when you need to run a code for multiple times.
The arrays [] :It is applied to group the variables and make it easier to manage.[/vc_column_text][vc_tour][vc_tab title=”Part list” tab_id=”1393913268-1-0″][vc_column_text]1. 8 x LED
2. 8 x R 33oΩ
3. 10 x Wire[/vc_column_text][/vc_tab][vc_tab title=”The code” tab_id=”1393913268-2-28″][vc_column_text]
int ledPins[] = {2,3,4,5,6,7,8,9};
When you need to manage lots of variables, an “array” is a very useful to put them together.
Here, we created a set of integers called ledpins, it has 8 quantities.
DigitalWrite (ledPins [0], HIGH);
You can describe each amount through the position in the array.
The location of the first element is 0, the second one is 0, and so on .
We use “ledPins [x]” to describe a quantity, where x show the location.
Here we set the digital interface 2 to HIGH (HIGH), because in the array the quantity of position 0 is 2.
The index = random (8);
Computer like doing the same thing when running.
But sometimes you like to do some random things, such as to throw the dice.
The random () function is a very good way.[/vc_column_text][/vc_tab][vc_tab title=”Test result” tab_id=”1393972605749-2-8″][vc_column_text]You will see:
It is similar to experiment 1 , but the multiple lamp blinking instead the one lamp .
If not the case, please make sure your circuit is properly connected, compile and upload the code to the board, or refer to the troubleshooting tips below.
Troubleshooting:
A few light are not bright
It’s very easy to insert a LED light,. Check the no bright lights, please make sure they are not inserted in the wrong direction.
lights are not in sequence
8 wire is easy to confuse. Please make sure the first lamp is inserted in the interface 2 ,the same way to check other lamp.
Start all over again
It is easy to ignore that the wire plug into the wrong place. Draw all line out and.
In the real world applications: scroll marquee display screen for that display some short important information.
They are made up of a lot of LED lights.[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.