Experiments in c with raspberry and arduino.
Documentation: WiringPi Core Functions
Wiring Pi Pinout:
- Raspbian OS
.img
file. - SD Card Formatter 0500
.exe
file. - VNC Viewer 6.18.907 for Windows 64bit
.exe
file. - win32diskimager 1.0.0 install
.exe
file.
- You need to go to
Control Panel > Networks & Internet > Network Connections
.
- Click on
Ethernet
option.
- Double click on
TCP/IPv4
option. - Instead of Automatic IP, choose Fixed IP Address.
- Configure it as follows:
- Accept changes.
- Put a microSD card (OS) inside the Raspberry.
- Connect a universal-USB cable from the Raspberry to your computer.
- Connect an Ethernet cable from the Raspberry to your computer.
- Open
VNC Viewer For Windows
(v6.18.907). - Choose the IP address of your Raspberry, in this case
192.168.0.144
.
- In VNC you will see the Raspberry's screen projected.
Note: Operating System inside the microSD Memory (32GB) is Linux Raspbian.
Through the terminal, go to the folder's directory where the source code is and type:
& gcc codename.c -o outputname -lwiringPi
& sudo ./outputname
- Click the Raspberry Icon.
- Click on Shutdown.
- Close VNC Viewer.
- Wait a few seconds and unplug the Ethernet and the Universal cables.
- In your computer, go back to
Control Panel > Networks & Internet > Network Connections
. - Choose Automatic IP Address again.
Pinout:
-
Download the Arduino IDE .exe file from here.
-
Connect your Arduino to your computer.
-
If your Arduino says in the back CH340G, you need to download another driver for the USB port to be recognized from this link. More details on this process were taken from here.
-
On the IDE, go to Tools > Board > Arduino Nano.
-
On the IDE, go to Tools > Processor > ATMega328P.
-
On the IDE, go to Tools > Port > COM4. This port can change, to see which one it takes, go to Device Manager > COM and LPT Ports > USB-SERIAL CH40 (COM4).
-
Open the .ino code that does something.
-
Click on Verify (check arrow on top-left corner).
-
Click on Upload (arrow beside the Verify button).
-
Open the serial port (console) to see the printed output. This button is on the top right corner.
-
Open the .ino code that does nothing.
-
Click on Upload.
-
Unplug the arduino.
You can simply just unplug the arduino.
Session 01 Led Blink
Small code that makes a led blink with a constant delay.
Session 02 Touch Sensor & Led
Small code that makes a led turn on while pressing a touch sensor.
Session 03 Passive Buzzer Plays Music Notes
Small code that sends a frequency number as voltage to a buzzer to make it play different notes.
Session 04 Temperature Printed in Console
Small code that prints in the console the Relative Humidity (%) and Temperature (°C and °F).
Session 05 Led Switch with Touch Sensor
Code that makes a led light switch on and off using a touch sensor as input.
Session 06 Arduino Nano & Ultrasonic Sensor
Code that prints the distance of obstacles using Arduino Nano and Ultrasonic Sensor.
Session 07 Arduino Nano & Ultrasonic Sensor With Touch Button
Code that prints the distance of obstacles using Arduino Nano and Ultrasonic Sensor, but only whenever a touch button is turned on.
Session 08 Arduino Nano & Ultrasonic Sensor Array
Code that prints the distance of obstacles stored in an array coming from 3 different ultrasonic sensors using Arduino Nano board.
Session 09 Vibration Motor Triggering With Ultrasonic Sensor Array
Code that stores the distance of detected objects of an array of ultrasonic sensors, and whenever an object is too close, its corresponding vibration motor vibrates for two seconds.