Ideation
This Week's assignment
Communicate wirelessly with a Smart Circuit via a Graphical User Interface (GUI) on my phone or PC.
Build a simple smart circuit that contains at least TWO action components that you can control wirelessly
Solar Panel
*This week's idea is about Solar Panel.
*I have some interest in providing Clear energy.
*I saw this idea, Love it I wish to implement it.
So
I have an idea that m projet will be a sunlight traker.
Tool Chain "Software * Materials * Machines "
Software
Arduino IDE
Tinker CAD
Arduino Bluetooth Control
Electronics Components
LDR sensor
Tow Servo motors
Arduino UNO
Jumpers
Breadboard
Servo Motor
Bl
LDR
Arduino
I Communicate wirelessly via a Bluetooth module to phone with a Smart Circuit via a Graphical User Interface (GUI) on your phone or PC.
Build a simple smart circuit that contains TWO action components (Two Servo Motors) I control wirelessly connected to an Arduino UNO board
programmed using Arduino C to perform serial communication
Manual Mode
Starting with manual mode.
Servo moves depending on light sensor "LDR"
Automatic Mode
Controlling in Servo by GUI "Graphical User Interface" software
App name "Arduino Bluetooth Control"
Arduino IDE
Using Arduino IDE software for coding " C (Text Code)"
Power Source
Arduino USB Cable .
Manual Mode
Manual Mode
Starting with manual mode.
Servo moves depending on light sensor "LDR"
Attach Servo with Pin 9
Photoresistor instead of LDR Attached with Pin A0
*.ino Code
file:///C:/Users/Jeasy-Othman/Desktop/SunFlower_Blutooth.htm
*.ino Code
file:///C:/Users/Jeasy-Othman/Desktop/Servo_Photoresistor%20W8.htm
#include <Servo.h>
Servo myServo;
const int sensorPin = A0;
int sensorValue = 0;
int angle;
void setup() {
myServo.attach(9);
Serial.begin (9600);
}
void loop() {
sensorValue = analogRead (sensorPin);
angle = map(sensorValue, 0, 1023, 0, 179);
myServo.write(angle);
delay (15);
}
Automatic Mode
Automatic Mode
Controlling in Servo by GUI "Graphical User Interface" software
App name "Arduino Bluetooth Control"
Attach Servo with Pin 9
Attach Servo with Pin 10
via a Bluetooth module to phone
I add with image editor software
#include <Servo.h>
char incomingData ;
Servo baseservo;
Servo servo1;
int pos = 0;
int pos1 = 0;
void setup() {
Serial.begin (9600);
baseservo.attach(9);
servo1.attach (10);
baseservo.write (pos);
servo1.write (pos1);
}
void loop() {
while (Serial.available() == 0);
incomingData = Serial.read ();
Serial.println (incomingData);
if (incomingData == '1' && pos <= 180 ) {
pos += 5;
baseservo.write (pos);
}
if (incomingData == '2' && pos >= 0 ) {
pos -= 5;
baseservo.write (pos);
}
if (incomingData == '3' && pos1 <= 180){
pos1 += 5;
servo1.write (pos1);
}
if (incomingData == '4' && pos1 >= 0) {
pos1 -= 5;
servo1.write (pos1);
}
incomingData == '0';
}
our code divided to 3 sections
- Header:
includes all the global variables and importing needed libraries
setup function
initializing the different pins and output/input components
Define Serial. Begin (9600) "The speed of data transfer between the two devices"
-loop function: do the main job as below
When I press 1 or 2 on Arduino software the first servo moves left & right "It moves five spin angles"
When I press 3 or 4 on Arduino software the first servo moves left & right "It moves five spin angles"
///
Circuits On breadboard wth Arduino
Manual Mode
Arduino
Breadboard
I supply the breadboard with GND & VCC from Arduino.
LDR sensor …. I connect
A0 = A0 on Arduino.
GND = GND on breadboard.
VCC = VCC on breadboard.
Servo Motor connection
GND = GND on breadboard.
Signal = Pin 9 on Arduino.
VCC = VCC on breadboard.
Automatic Mode
Arduino
Breadboard
I supply the breadboard with GND & VCC from Arduino.
LDR sensor …. I connect
A0 = A0 on Arduino.
GND = GND on breadboard.
VCC = VCC on a breadboard.
Servo1 Motor connection
GND = GND on a breadboard.
Signal = Pin 9 on Arduino.
VCC = VCC on a breadboard.
Servo2 Motor connection
GND = GND on a breadboard.
Signal = Pin 10 on Arduino.
VCC = VCC on a breadboard.
Bluetooth connection
GND = GND on breadboard.
VCC = VCC on breadboard.
TXD = RXD on Arduino.
RXD = TXD on Arduino.
Two Sunflowers
Putting SunFlowers on Servos
I Craft Two Sunflowers to represent my SMART Tracker.
Overcoming Ghallenge
Wifi Module on Tinker CAD
There are no longer Wifi modules or Bluetooth on Tinker CAD.
I did not know how to overcome this till now.
Controlling two moods "Bug"
Another Challenge
I had a bug in my code that I added the incoming data and all syntax needed to switch between manual mood to an automatic one
and thought then that I can control servos with tolerance "LDR readings" with GUI
I asked for help from the Instructor, I learned that we cannot control two different ways at the same time "Manual & Automatic"
Debugging
Sharing with Family & Friends.
This Week I'm able to بفضل الله ^^
Program an Arduino Uno board to do serial communication through a wire (USB)
Program an Arduino Uno board to do serial communication wirelessly (Via Bluetooth)
Use a simple Graphical User Interface on PC to control a smart circuit wirelessly (Via Bluetooth)
Use a simple Graphical User Interface on a phone to control a smart circuit wirelessly (Via Bluetooth)