Very Basic Arduino Uno Board Testing

Thread Tools Search this Thread
Top Forums Programming Very Basic Arduino Uno Board Testing
# 1  
Old 12-19-2019
Very Basic Arduino Uno Board Testing

A very simple Arduino board test... LOL

Here is some very easy code to test a cheap Arduino board I just got from China via Aliexpress. I am still waiting on a about 30 more orders from Aliexpress for more Arduino stuff. This was the first order which made it here.

Arduino test-code
This code is intended to be used for an easy introduction to the Arduino board. 
The program reads data from 2 digital and 2 analog ports and prints the values to the monitor with a sampling speed of 1 Hz.

int counter = 0, analog0, analog1; //Creates variables as integers
float analog0_volt, analog1_volt;  //Creates variables as floating numbers.
boolean digital2, digital3;        //Creates variables as boolean (HIGH or LOW, TRUE or FALSE)

void setup()
{                             //Setup. This section runs only once.
    Serial.begin(9600);       //Sets the communication speed between PC and Arduino Uno to 9600 baud.
    pinMode(2, INPUT);        //Sets the digital 2 pin to input mode (High impedance).
    pinMode(3, INPUT_PULLUP); //Sets the digital 2 pin to input mode with "Pull Up" (High impedance and Normal High).
    delay(500);               //0.5 seconds break.
} //end of setup

void loop()
{ //Loop. This section runs in an unending loop.
    //Collect data from all the inputs
    analog0 = analogRead(A0);  //Reads data from analog port 0 and stores it in the variable "analog0".
    analog1 = analogRead(A1);  //Reads data from analog port 1 and stores it in the variable "analog1".
    digital2 = digitalRead(2); //Reads data from digital port 2 and stores it in the variable "digital2".
    digital3 = digitalRead(3); //Reads data from digital port 3 and stores it in the variable "digital3".
    //Note the difference between pin numbering in analog (Ax) and digital (x).

    //Convertion from digital value to voltage value
    analog0_volt = ((float)analog0 / 1023) * 5; //Scales from 0-1023 (integers) to 0.0-5.0 (decimal numbers). 0=0V 1023=5V.
    analog1_volt = (analog1 / 1023.0) * 5;      //Does the same as the previous line. Notice the difference in the syntax.

    //Print out data to the monitor
    Serial.print(counter);         //Prints out the variable "counter".
    Serial.print("  - Analog0: "); //Prints the text inside the brackets "__".
    Serial.print(analog0_volt);    //Prints out the variable "analog0_volt".
    Serial.print("   Analog1: ");  //Prints the text.
    Serial.print(analog1_volt);    //Prints out the variable "analog1_volt".
    Serial.print("   Digital2: "); //Prints the text.
    Serial.print(digital2);        //Prints out the variable "digital2".
    Serial.print("   Digital3: "); //Prints the text.
    Serial.println(digital3);      //Prints out the variable "digital3" and ends with a line shift.

    delay(1000); //A 1000ms delay.
    counter++;   //Increments the variable "counter".

} //end of function (Returns to start of loop).

//The program inside the loop function will continue forever and ever, or until power down.

Using the Arduino IDE on the mac I uploaded the code above into my new cheap Chinese Arduino board and set up a simple test before I get into some more interesting stuff.

Very Basic Arduino Uno Board Testing-img_8679jpg

Very Basic Arduino Uno Board Testing-img_8678jpg

Well, at least the board works, the Arduino IDE on my mac works, etc.....
Very Basic Arduino Uno Board Testing-screen-shot-2019-12-19-81059-pmpng

This is gonna be fun, I can tell Smilie

I think I am going to build something for my motorcycle (not sure yet), using a 3G module like this one:


Elecrow GSM/GPRS/EDGE SIM5360E 3G Shield for Arduino Uno Mega Module A-GPS Micro SIM Card 3G Network eCALL Development Board
Or maybe I'll do some home automation for fun; so I can control things with SMS messages; or both.
These 2 Users Gave Thanks to Neo For This Post:
# 2  
Old 12-19-2019
Getting free of the Arduino IDE serial monitor, this python code works.

First, on the mac, import pyserial:

sudo pip install pyserial

macos# cat

The code:

import serial

ser = serial.Serial(

print("connected to: " + ser.portstr)

# this will store the line
line = []

while True:
    for c in
        if c == '\n':
            print("Line: " + ''.join(line))
            line = []


Run it:


Output from Arduino on my mac using python to read it:

macos$ python
connected to: /dev/cu.usbserial-40
Line: 0  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 1  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 2  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 3  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 4  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 5  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 6  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 7  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Line: 8  - Analog0: 5.00   Analog1: 3.33   Digital2: 0   Digital3: 0

Well, this is a bit too easy..... we all can easily set up all kind of sensors in our homes, in our motorcycles or cars, and push the results to a DB on the net and display the results on the web.... even on this site. Or M2M....

# 3  
Old 12-19-2019
You can do some pretty rinky dink seasonal (Christmas) stuff with an Arduino and strips of LEDs like WS2812b (Google that).

You just need to connect a pin of the strip to 5V, another to GND, and a third to an output pin. I use the FastLED library.
You can program sequences of chasing lights, colour changes, and anything else that you want to do.

I had a problem recently in trying to get outputs (eg, LED flashing) at different frequencies (intervals)) given the single thread available on an Arduino. I got around this by using the modulo function. I'll attach the demo code a wrote for this before I wrote the production stuff.

Also, I got hacked off with trying to program LED flashing (on analogue and/or digital output pins) a number of required times and also fading up or down at the same time. For example, fade a LED up, flash it 4 times, then fade it down. I thought that there had to be an easier way so I wrote "ulcf" (Universal LED Control Function) to allow me to call my requirements in one line of code (or perhaps 2 or 3 calls of the function to get the effect that I want). I'll attach this code to this post too but I'm not saying it's fully debugged but you'll get the drift.

How many electronics engineers are there on this forum who mess about with the likes of Arduino? Show of hands please.

PS. Had to upload files as .txt - site refuses to upload .ino
This User Gave Thanks to hicksd8 For This Post:
# 4  
Old 12-19-2019
Originally Posted by hicksd8
PS. Had to upload files as .txt - site refuses to upload .ino

If you gzip the .ino file, you can upload it.


OBTW, I have a 5 meter strip of LED lights (red, blue, green) I got from Aliexpress for about $4 dollars, including an IR controller. I was thinking to plug the strip directly (omitting the IR controller that came with the strip) into an Arduino project for fun as well. It's currently running off an old car battery on my balcony.
# 5  
Old 12-19-2019
Ok, if you have an LED strip I can send you some code that I wrote for a SMET2 (in the UK that's a Smart Electricity Meter that can be read remotely by the supplier) demonstration. The LED strip was 52 LED's long and demonstrates the supplier sending out a meter read request (3 stages of LED strip light following) and the reverse to demonstrate the data coming back from the smart meter. It was used on a recent demo board at a renewable energy show. Anyway, it's just a demo if you want the code. 52 LED strip (or longer) for full effect.
This User Gave Thanks to hicksd8 For This Post:
# 6  
Old 12-19-2019

I need to put the meter on the four wire output of the IR controller and get a better understanding of this three light strip (the resistance and the voltage).

At this rate, I will buy that new Rigol 1054Z sooner than later!

In my Aliexpress shopping cart for a few weeks now:


RIGOL DS1054Z 50MHz Digital Oscilloscope 4 analog channels 50MHz bandwidth

# 7  
Old 12-19-2019
@neo..........I've sent you an email with the code attached.

I cannot drop this into the public domain right now, however, anyone else who wants a copy just give me a shout.
This User Gave Thanks to hicksd8 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Basic Arduino UNO Bluetooth Testing with the BLE 4.0 (CC2541, MLT-BT04 IC)

Here is a sketch to do basic testing for the Arduino UNO and the MLT-BT04. This BLE module works with IOS (iPhone) and I'll add some details on my IOS testing with an iPhone in a follow-up post. For now, here is the basic BLE (HM-10) sketch for the Arduino UNO: /* Arduino test-code... (7 Replies)
Discussion started by: Neo
7 Replies

2. Programming

Arduino UNIX Time - Syncing Computer UNIX Time to Arduino Time with Python

Just finished a quick Python script to send the current unix time over to the Arduino from macOS, so in the absence of GPS or some other way to get the unix timestamp (epoch time) to the Arduino, I can get my macOS and Arduino UNO synced to within a second. Normally, when the Arduino starts... (9 Replies)
Discussion started by: Neo
9 Replies

3. Programming

Chinese Arduino UNO Clones - The Wavgat versus the generic UNO R3 Clone - The Winner Is?

Waiting for more fun Ardunio parts from AliExpress, I decided to test two cheap Chinese Arduino UNO clones. The Arduino UNO R3 (CH340G) MEGA328P The Wavgat UNO R3 (CH340G) MEGA328P Both of these Chinese Ardunio clones sell for about $3 USD, delivered to your door. The bottom line is... (0 Replies)
Discussion started by: Neo
0 Replies

4. Programming

More Arduino Stuff...

HI all... (Apologies for any typos.) To add to Neo's Arduino subject matter I have decided to upload this in ".zip" format. Ignore "*.info" files these are AMIGA icons only and also the "HAM" drawer as these are photos in ancient AMIGA HAM modes. I have noticed that there are current... (6 Replies)
Discussion started by: wisecracker
6 Replies

5. Programming

Arduino-cli - Uploading to Unknown Chinese Arduino Boards using the Arduino Command Line Interface

In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today. I followed the instructions for macOS but when I got to this part: arduino-cli board list I got the dreaded "Unknown" Fully Qualified Board Name... (1 Reply)
Discussion started by: Neo
1 Replies

6. OS X (Apple)

Semi-Automatic Arduino Detection.

I am working on a semi-auto detection idea for Arduino for the Scope project. It does require a little user intervention but minimal. It works by just responding to two on screen prompts to unplug and plug Arduino into a USB port. There are two versions and both work perfectly well and give... (3 Replies)
Discussion started by: wisecracker
3 Replies

7. OS X (Apple)

Arduino Diecimila Board Access...

This is a very simple starter DEMO to access Arduino Diecimila Board for the Macbook Pro 13" OSX 10.7.5... A potentiometer is connected between 5V and Gnd with the wiper connected to ANALOG IN 0 on the Arduino. This was adjusted to give the Ms and Ls as seen... I now have DC in for this... (0 Replies)
Discussion started by: wisecracker
0 Replies

8. Shell Programming and Scripting

Use The Terminal To Test Arduino Is Working.

Hi all... (Apologies for any typos at all.) This is a step by step _script_ to check if your Arduino is talking to your Linux or Macbook Pro computer using the Terminal... It works on at least 3 Linux flavours and now the Macbook Pro... I hope you find it useful as a simple check for... (0 Replies)
Discussion started by: wisecracker
0 Replies
Login or Register to Ask a Question

Featured Tech Videos