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.
Code:
/*
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.
Well, at least the board works, the Arduino IDE on my mac works, etc.....
This is gonna be fun, I can tell
I think I am going to build something for my motorcycle (not sure yet), using a 3G module like this one:
Code:
https://www.aliexpress.com/item/32814966264.html
Quote:
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.
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)
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)
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)
In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today.
https://github.com/arduino/arduino-cli
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)
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)
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)
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)
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)