วันเสาร์ที่ 28 กรกฎาคม พ.ศ. 2561

technology Open Menu EAL - ARDUINO HOVERCRAFT

Step 1: Part List

Picture of Part List
Picture of Part List
Picture of Part List
Picture of Part List
Picture of Part List
Picture of Part List
Picture of Part List
1. The base part of the hovercraft is made of flamingo. We used a big square of it, that we cut out in the wanted dimensions and made the front-end circular.
2. 2x DC motors, for rotating the propel and the fan.
3. A stepper motor driver
4. A frame, for holding the motors. For our hovercraft, we made the frame out of wood and acryl.
5. A bluetooth module, for controlling the hovercraft. We used a HC-05 Bluetooth Module.
6. Arduino board, breadboard, wires, 9v batteries and a 12v adapter. We used the Arduino Mega 2560.
7. Propeller + Fan. We downloaded our propeller from Thingiverse, and printed them at our school (http://www.thingiverse.com/thing:1733112 ) We use the same propeller as propel and fan, but removed the outer circle on the fan.

Step 2: Making the Boat

Picture of Making the Boat
Picture of Making the Boat
Picture of Making the Boat
Picture of Making the Boat
Picture of Making the Boat
In the center of the base, we cut a hole for the fan, which is going to levitate the hovercraft.
On the bottom, we wrapped on a plastic bag, and poked a lot of small holes in it, to make the air run through, and make the hovercraft levitate
We then used duct tape to secure the plastic bag, and to make sure that the flamingo does not dissolve into small pieces.
The frame was then placed on top of the hovercraft, and held together with glue. On top of the frame, and above the hole is an acrylic plate, for mounting the motors.
The propel/fan is glued to the motors and the motors and glued to the acrylic plates.

Step 3: The Mechanical Part

Picture of The Mechanical Part
Picture of The Mechanical Part
Picture of The Mechanical Part
First part is to wire the arduino. We use 1x 9v battery to power the arduino, trough the 12v adapter
We then wire the motor driver to the arduino to pin 3+4 for the propel and pin 8+9 for the fan.
Then we wire the motors to the motor driver. The motor driver is also wired to ground, and to 3 parallel connected 9v batteries, theese power the motors.
We then wire the bluetooth module to the arduino, through a breadboard, because we need to have resisters between.

Step 4: Software

Picture of Software
Picture of Software
For controlling the hovercraft, we use bluetooth, and then controls the hovercraft from our smartphone.
For making the app for our smartphone, we used the free online program, MIT App Inventor (http://appinventor.mit.edu). From our phone, we can now make the hovercraft move forward, backwards and stop.
We programmed our arduino board in the free Arduino program.
<p>/*<br> 
 */
 
int motor1Pin1 = 3; // Makes the hovercraft go forward
int motor1Pin2 = 4; // Makes the hovercraft go backward</p><p>int motor2Pin1 = 8; // Turns on the fan
int motor2Pin2 = 9; //</p><p>int state;
int flag=0;        //makes sure that the serial only prints the state once
int stateStop=0;
void setup() {
    // sets the pins as outputs
    pinMode(motor1Pin1, OUTPUT);
    pinMode(motor1Pin2, OUTPUT);</p><p>    pinMode(motor2Pin1, OUTPUT);
    pinMode(motor2Pin2, OUTPUT);</p><p>    // initialize serial communication at 9600 bits per second
    Serial.begin(9600);
}</p><p>void loop() {
    //if some data is sent, reads it and saves in state
    if(Serial.available() > 0){     
      state = Serial.read();   
      flag=0;
    }   
    // if the state is 'F' the Hovercraft will go forward
    if (state == 'F') {
        digitalWrite(motor1Pin1, HIGH);
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, HIGH);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
          Serial.println("Go Forward!");
          flag=1;
        }
    }
    
    // if the state is 'S' the hovercraft will turn off
    else if (state == 'S' || stateStop == 1) {
        digitalWrite(motor1Pin1, LOW); 
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, LOW);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
          Serial.println("STOP!");
          flag=1;
        }
        stateStop=0;
    }</p><p>    // if the state is 'B' the hovercraft will go backwards
    else if (state == 'B') {
        digitalWrite(motor1Pin1, LOW); 
        digitalWrite(motor1Pin2, HIGH);
        digitalWrite(motor2Pin1, HIGH);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
          Serial.println("Reverse!");
          flag=1;
        }
    }

Building a Simple Arduino Robot

This guide shows you how to quickly and easily build an Arduino robot. Robotics is an exciting and fun hobby that has become very affordable in recent years. What would have required a lot of money and experience to do a few decades ago is now affordable, easy, and most of all, FUN!
.
Simple Arduino Robot
The parts used in this guide can all be purchased together in the Funduino UNO Robotics Kit, but you can follow along with a different kit just as easily as long as you have similar components.
Keep in mind that this tutorial shows just one way to make a robot — you’re limited only by your budget and imagination. If you want to buy more sensors, or a nicer chassis, go for it! The entire process may take an hour or two, so get ready to have some fun!//PERFECT RUNNING PROGRAM FOR ONE ULTRASONIC + SERVO + 2 DC MOTOR BASED //ROBOT CAR 
// REGARDS ENG.SURESH KUMAR CONTACT AT suresh.kkes@gmail.com
#include <servo.h>
const int trigPin = 11;
const int echoPin = 8;
const int MotorAn = 10;
const int MotorAp = 9;
//Motor B
const int MotorBn = 5;
const int MotorBp = 3;
Servo myservo;
int pos = 75;
void setup() {
Serial.begin(5000);
myservo.attach(12);
}
void loop()
{
long duration, inches, cm;
pinMode(MotorAn, OUTPUT);
pinMode(MotorAp, OUTPUT);
pinMode(MotorBn, OUTPUT);
pinMode(MotorBp, OUTPUT);
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
if (inches <= 6)
{
sweep(1);
Serial.println ("Motion Backwards");
}
else if (inches >= 6)
{
myservo.write(pos);
delay(100);
Serial.println ("Motion Forward");
digitalWrite (MotorAn,HIGH);
digitalWrite (MotorAp,LOW);
digitalWrite (MotorBn,HIGH);
digitalWrite (MotorBp,LOW);
}}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
void sweep(int turn)
{
for (int j=0; j<turn; j++)="" digitalwrite="" (motoran,low);="" digitalwrite="" (motorap,low);="" digitalwrite="" (motorbn,low);="" digitalwrite="" (motorbp,low);="" for(pos="-10;" pos="" <="" 180;="" pos="" +="2)" {="" myservo.write(pos);="" delay(10);="" }="" digitalwrite(motoran,="" high);="" digitalwrite(motorap,="" low);="" delay(10);="" for(pos="150;" pos="">=75; pos-=2) {
myservo.write(pos);
delay(10); }
myservo.write(pos);
delay(10);
}
(อ้างอิง) https://makezine.com/projects/building-a-simple-arduino-robot/

SIMPLE RC CAR FOR BEGINNERS (ANDROID CONTROL OVER BLUETOOTH) By tolik777 in TechnologyRobots72

This is a simple project of Android Bluetooth Car with Bluetooth control. Arduino controller is used
To control the car used Android-device with a built-in accelerometer. Tilt forward - car goes forward, tilt to the left - car turns to the left, tilt back - car goes back. Speed of movement or rotation depends on how much you tilt the device. Sensitivity and value of the tilt set in the configuration Android-apps. Also are provided a normal way to control: the buttons on the screen. In addition to all I implemented the touch control. Total 3 ways to control the RC Car.
Capabilities of the device you can see on the video above

Step 1: Android Device

Picture of Android Device
Parts needed
1. Android device
The most important part - Android device with accelerometer and Bluetooth: tablet, smartphone and other... As an Android device, I used a cheap Chinese tablet "Ainol Aurora" with an external USB-Bluetooth module (because its not have own), connected via USB Host.

Step 2: DIY Car Chassis

Picture of DIY Car Chassis
Picture of DIY Car Chassis
2. DIY Car Chassis
We also need any chassis with 2 or 4 DC motors. You can use an old RC toy car. As a platform I used a small RC DIY platform, bought on AliExpress for 25$. It's most suitable track chassis for this project.

Step 3: Controller (MCU)

Picture of Controller (MCU)
3. Controller (MCU)
You need any Arduino-compatible controller (Nano, Uno, Leonardo, Mini and other)
The controller should contain 2 PWM and UART.

Step 4: Bluetooth Module

Picture of Bluetooth Module
4. Bluetooth module
As a Bluetooth module uses cheap Chinese module Bluetooth Serial HC-06 (3-4$ on AliExpress). Instructions guide on connecting bluetooth module to Arduino is here.
You can use HC-05, HC-07 and other serial Bluetooth modules

Step 5: Motor Driver

Picture of Motor Driver
5. Motor Driver
I used L298N Dual Bridge DC stepper Motor Driver module. It cost 3-5$ on AliExpress.

Step 6: Other Parts

Picture of Other Parts
6. Other parts

Step 7: Theory

Picture of Theory
Theory
All calculations are performed in the Android-application, and immediately calculate the values 2‹2‹of the PWM for the left and right motor. Application has flexible settings, such as the range of the PWM, the sensitivity of tilt, the minimum threshold for the PWM and other. Example commands transmitted by Bluetooth:
L-255\rR-120\r
L - the command to the left engine, R - for the right
A dash means the motor rotation to move back
255 - PWM value (for Arduino is the maximum speed of rotation)
\r - end of command.
On this command RC car will move forward and slightly rotated to the right, as right engine rotates slowly left.
L255\rR-255\r
On this command the left engine will rotate back and forward right, forcing a car to rotate around its axis counterclockwise.
H1\r
Command is an additional channel to which you can connect for example lights, sound, etc.
Symbols command L, R and H can be defined in the settings of Android-applications.
In the MCU control program provides a timer that shuts off the engine if the last command was received more than n-seconds ago. The data are stored in the EEPROM memory of the controller and can be changed from Android device. The range of this setting is from 0.1 seconds to 99.9 seconds. This setting can be disabled. To work with EEPROM provides commands: Fr - reading values 2‹2‹and Fw - record values.
Electronics
Block diagram see on picture above

Step 8: Android Application

Picture of Android Application
Picture of Android Application
Picture of Android Application
As we can see, the Arduino connects to Bluetooth module and a motor driver with two or four connected motors.
Android Application
The application for Android was written in Eclipse IDE. All sources of the project and the project for Eclipse, you can download below. Android version on your device must be > 3.0.
The application contains several activity. Main activity is a home screen with buttons running different operating modes and settings
There are 3 control modes Bluetooth-car: from accelerometer, screen buttons and touch-control.
Android application settings
Screenshot of settings CxemCar Android application version 1.0
MAC address
To establish a connection with the RC Car's Bluetooth module, you must set MAC-address in the application settings. But first, you must configure the pair the devices on Android-device: open Settings -> Bluetooth and click "Search for devices". When the phone finds our Bluetooth-module, click them and enter password for pairing (usually "1234")
To know Bluetooth module MAC-address possible from any application, such as Bluetooth Terminal. To do this, click "Connect a device - Secure" and in the resulting window, click the button "Scan for devices". Software will be scans the Bluetooth devices and displays them MAC-address.

Step 9: Arduino RC Car Wiring

Picture of Arduino RC Car Wiring
Picture of Arduino RC Car Wiring
Picture of Arduino RC Car Wiring
Picture of Arduino RC Car Wiring
Picture of Arduino RC Car Wiring
Wiring diagram for Arduino controller
In the circuit I used a jumper (in the scheme Jmp1), because with a connected Bluetooth module is impossible be load sketch to the Arduino.
I soldered a Bluetooth-module to the Arduino and led status light. For communication between Arduino and Bluetooth, read this article: Arduino and Bluetooth. Module HC-06 placed in heat-shrink tube 10mm. Bluetooth-state LED with current limiting resistor (calculator) were also placed in heat-shrink tube.
In the breadboard platform, I drilled a hole and secure motor driver L298N. Arduino board attached with double-sided tape
Between the car platform and breadboard I placed 3 Li-Po battery 3.7V 1100 mAh. Power to the controller and motors separately: Arduino powered by a 3.7 V battery, and the motors and driver L298N from two 3.7V batteries connected in series. There are two 2-position power switch - one position is the power from the batteries to consumers, in the other position to charging terminals.
Beetween BT pin RX (2) and Arduino pin TX may require level shifter. For this, you can use voltage divider: calculator 5V to 3.3V


Step 10: Software

Picture of Software
The program was written in Arduino IDE 1.01.

#include "EEPROM.h"
#define D1 2 // direction of motor rotation 1
#define M1 3 // PWM left motor
#define D2 4 // direction of motor rotation 2
#define M2 5 // PWM right motor
#define HORN 13 // additional channel 1
//#define autoOFF 2500 // milliseconds after which the robot stops when the connection
#define cmdL 'L' // UART-command for left motor
#define cmdR 'R' // UART-command for right motor
#define cmdH 'H' // UART-command for additional channel (for example Horn)
#define cmdF 'F' // UART-command for EEPROM operation
#define cmdr 'r' // UART-command for EEPROM operation (read)
#define cmdw 'w' // UART-command for EEPROM operation (write)
char incomingByte; // incoming data
char L_Data[4]; // array data for left motor
byte L_index = 0; // index of array L
char R_Data[4]; // array data for right motor
byte R_index = 0; // index of array R
char H_Data[1]; // array data for additional channel
byte H_index = 0; // index of array H
char F_Data[8]; // array data for EEPROM
byte F_index = 0; // index of array F
char command; // command
unsigned long currentTime, lastTimeCommand, autoOFF;
void setup() {
Serial.begin(9600); // initialization UART
pinMode(HORN, OUTPUT); // additional channel
pinMode(D1, OUTPUT); // output for motor rotation
pinMode(D2, OUTPUT); // output for motor rotation
/*EEPROM.write(0,255);
EEPROM.write(1,255);
EEPROM.write(2,255);
EEPROM.write(3,255);*/
timer_init(); // initialization software timer
}
void timer_init() {
uint8_t sw_autoOFF = EEPROM.read(0); // read EEPROM "is activated or not stopping the car when losing connection"
if(sw_autoOFF == '1'){ // if activated
char var_Data[3];
var_Data[0] = EEPROM.read(1);
var_Data[1] = EEPROM.read(2);
var_Data[2] = EEPROM.read(3);
autoOFF = atoi(var_Data)*100; // variable autoOFF ms
}
else if(sw_autoOFF == '0'){ 
autoOFF = 999999;
}
else if(sw_autoOFF == 255){
autoOFF = 2500; // if the EEPROM is blank, dafault value is 2.5 sec
}
currentTime = millis(); // read the time elapsed since application start
}
void loop() {
if (Serial.available() > 0) { // if received UART data
incomingByte = Serial.read(); // raed byte
if(incomingByte == cmdL) { // if received data for left motor L
command = cmdL; // current command
memset(L_Data,0,sizeof(L_Data)); // clear array
L_index = 0; // resetting array index
}
else if(incomingByte == cmdR) { // if received data for left motor R
command = cmdR;
memset(R_Data,0,sizeof(R_Data));
R_index = 0;
}
else if(incomingByte == cmdH) { // if received data for additional channel
command = cmdH;
memset(H_Data,0,sizeof(H_Data));
H_index = 0;

else if(incomingByte == cmdF) { // if received data for EEPROM op
command = cmdF;
memset(F_Data,0,sizeof(F_Data));
F_index = 0;
}
else if(incomingByte == '\r') command = 'e'; // end of line
else if(incomingByte == '\t') command = 't'; // end of line for EEPROM op
if(command == cmdL && incomingByte != cmdL){
L_Data[L_index] = incomingByte; // store each byte in the array
L_index++; // increment array index
}
else if(command == cmdR && incomingByte != cmdR){
R_Data[R_index] = incomingByte;
R_index++;
}
else if(command == cmdH && incomingByte != cmdH){
H_Data[H_index] = incomingByte;
H_index++;

else if(command == cmdF && incomingByte != cmdF){
F_Data[F_index] = incomingByte;
F_index++;

else if(command == 'e'){ // if we take the line end
Control4WD(atoi(L_Data),atoi(R_Data),atoi(H_Data));
delay(10);
}
else if(command == 't'){ // if we take the EEPROM line end
Flash_Op(F_Data[0],F_Data[1],F_Data[2],F_Data[3],F_Data[4]);
}
lastTimeCommand = millis(); // read the time elapsed since application start
}
if(millis() >= (lastTimeCommand + autoOFF)){ // compare the current timer with variable lastTimeCommand + autoOFF
Control4WD(0,0,0); // stop the car
}
}
void Control4WD(int mLeft, int mRight, uint8_t Horn){
bool directionL, directionR; // direction of motor rotation L298N
byte valueL, valueR; // PWM M1, M2 (0-255)
if(mLeft > 0){
valueL = mLeft;
directionL = 0;
}
else if(mLeft < 0){
valueL = 255 - abs(mLeft);
directionL = 1;
}
else {
directionL = 0;
valueL = 0;
}
if(mRight > 0){
valueR = mRight;
directionR = 0;
}
else if(mRight < 0){
valueR = 255 - abs(mRight);
directionR = 1;
}
else {
directionR = 0;
valueR = 0;
}
analogWrite(M1, valueL); // set speed for left motor
analogWrite(M2, valueR); // set speed for right motor
digitalWrite(D1, directionL); // set direction of left motor rotation
digitalWrite(D2, directionR); // set direction of right motor rotation
digitalWrite(HORN, Horn); // additional channel
}
void Flash_Op(char FCMD, uint8_t z1, uint8_t z2, uint8_t z3, uint8_t z4){
if(FCMD == cmdr){ // if EEPROM data read command
Serial.print("FData:"); // send EEPROM data
Serial.write(EEPROM.read(0)); // read value from the memory with 0 address and print it to UART
Serial.write(EEPROM.read(1));
Serial.write(EEPROM.read(2));
Serial.write(EEPROM.read(3));
Serial.print("\r\n"); // mark the end of the transmission of data EEPROM
}
else if(FCMD == cmdw){ // if EEPROM data write command
EEPROM.write(0,z1); // z1 record to a memory with 0 address
EEPROM.write(1,z2);
EEPROM.write(2,z3);
EEPROM.write(3,z4);
timer_init(); // reinitialize the timer
Serial.print("FWOK\r\n"); // send a message that the data is successfully written to EEPROM
}

(อ้างอิง: https://pin.it/xiiapmz6qqycoe) 

วันอาทิตย์ที่ 15 กรกฎาคม พ.ศ. 2561

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

RTC_DS1307 RTC;
Adafruit_7segment disp = Adafruit_7segment();

void setup() 
{
  Wire.begin();
  RTC.begin();
  if (! RTC.isrunning()) 
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  disp.begin(0x70);
}

void loop() 
{
  disp.print(getDecimalTime());
  disp.drawColon(true);
  disp.writeDisplay();
  delay(500);
  disp.drawColon(false);
  disp.writeDisplay();
  delay(500);
}

int getDecimalTime()
{
  DateTime now = RTC.now();
  int decimalTime = now.hour() * 100 + now.minute();
  return decimalTime;
}
  1. /*
  2. Adafruit Arduino - Lesson 12. Light and Temperature
  3. */
  4.  
  5. #include <LiquidCrystal.h>
  6.  
  7. int tempPin = 0;
  8. int lightPin = 1;
  9.  
  10. // BS E D4 D5 D6 D7
  11. LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
  12.  
  13. void setup()
  14. {
  15. lcd.begin(16, 2);
  16. }
  17.  
  18. void loop()
  19. {
  20. // Display Temperature in C
  21. int tempReading = analogRead(tempPin);
  22. float tempVolts = tempReading * 5.0 / 1024.0;
  23. float tempC = (tempVolts - 0.5) * 100.0;
  24. float tempF = tempC * 9.0 / 5.0 + 32.0;
  25. // ----------------
  26. lcd.print("Temp F ");
  27. lcd.setCursor(6, 0);
  28. lcd.print(tempF);
  29. // Display Light on second row
  30. int lightReading = analogRead(lightPin);
  31. lcd.setCursor(0, 1);
  32. // ----------------
  33. lcd.print("Light ");
  34. lcd.setCursor(6, 1);
  35. lcd.print(lightReading);
  36. delay(500);
  37. }

Internet of Things (IoT)

Internet of Things หรือ IoT  Internet of Things (IoT)  คือ การที่อุปกรณ์อิเล็กทรอนิกส์ต่างๆ สามารถเชื่อมโยงหรือส่งข้อมูลถึงกันได้ด้วยอิ...