background image

37

Open the serial port assistant software "HMComAssistant.exe" and select the Arduino port and set 
baud(115200) for bluetooth, then press “Open Com” and enter the data you want to send to 
bluetooth(1 or 0 in our demo code). Finally, press “Send” to send the data to control the LED on and 
off. When you enter the data ‘1’ and send it, the LED will light on and receive the prompt “LED ON”. 
When you send the data "0", the LED will lights off and receive the prompt "LED OFF".

What will you see

1. Declare the pin of led, and a variable to store the data we send from the serial port.
2. Setup the led as output and initialize the serial monitor and set the baud(115200) that correspond 
to our bluetooth.
3. Check if the serial port has received the data from bluetooth. If yes, store the data in the variable 
“state”.
4. If data received is “0”, turn LED off.
5. If data received is “1”, turn LED on.

Code overview

Code usage

Set the baud for serial monitor correspond to our bluetooth module. “115200” is the default baud rate 
for our bluetooth module. If we set the wrong baud for Arduino serial monitor, it may cause
communication failure or garbled communication between Bluetooth and Arduino.

Serial baud rate: Serial.begin(115200);

Determine if the serial monitor has received data. We send the data to Bluetooth, and then Bluetooth 
sends the data to the Arduino serial monitor. If we send data, the expression "Serial.available ()> 0" is 
true, otherwise it is false.

Received data: Serial.available()>0

Function to read data from the serial monitor. Then, we store the data in the variable "state", and we 
turn on or off the led based on the value of this variable.

Read serial data: state = Serial.read();

This is Crowtail- ESP8266 Node MCU, it adds six crowtail interfaces on the board, so you can easily 
use this board with other crowtail modules.  We intergrate a USB-Serial chip that can upload code. 

Lesson 18 – ESP8266 web server

Introduction

Содержание Crowtail Deluxe Kit

Страница 1: ...www elecrow com 2020 ELECROW All Rights Reserved C User Guide V2 0 2020 02 Crowtail Deluxe Kit for Arduino...

Страница 2: ...erature reminder Lesson 7 Colorful RGB light Lesson 8 Show text on OLED Lesson 9 Ultrasonic ranging display Lesson 10 Use of the joystick Lesson 11 Servo control Lesson 12 Smart door Lesson 13 IR cont...

Страница 3: ...o build a smart car completely including wireless remote control intelligent tracking or obstacle avoidance etc Of course there are more complex move ment data acquisition wifi and Bluetooth use The C...

Страница 4: ...mb Joystick x1 Crowtail IR Receiver x1 Crowtail IR Emitter x1 Crowtail Hall Sensor x1 Crowtail One Wire Waterproof Temperature Sensor x1 Crowtail Collision Sensor x1 Crowtail Ultrasonic Ranging Sensor...

Страница 5: ...their own DIY mobile platform motor drive has always been a problem It need 2 DC motors at least to control their speed direction of rotation because you will want your platform forward turn back tur...

Страница 6: ...used for UART communication such as the WIFI module or Bluetooth module 1 IIC ports A4 A5 that have a mark of I These interfaces are for the IIC Communication Besides there is also two motor connector...

Страница 7: ...OW signal In fact it is very similar to the button except that the switch has a self locking function so that it can output logic high level signal without pressing it all the time In this lesson we a...

Страница 8: ...ed as an output and switch as an input Digital Input We use the digitalRead function to read the value on a digital pin Check to see if an input pin is reading HIGH 5V or LOW 0V Returns TRUE 1 or FALS...

Страница 9: ...mart car Lesson 2 Collision experiment Introduction Arduino Uno Crowduino Uno x1 Crowtail Motor Base Shield x1 Crowtail Collision Sensor x1 Crowtail LED x1 Crowtail Buzzer x1 Crowtail Cable x3 Require...

Страница 10: ...iable First Macro defined constants cannot be changed while the program is running Variables can be changed Second the variable can be used inside the function defined by it but the life cycle end whe...

Страница 11: ...l port monitor When you use the magnet s S polar to approach the hall sensor the red indicator light on the hall sensor will light up and the speed count will increase by one When you repeat the actio...

Страница 12: ...rigger when change RISING low level to high level trigger FALLING high level to low level trigger We use a Hall sensor as the interrupt source connected to the D3 port When the interrupt occurs the S...

Страница 13: ...which can drive two motors at the same time Of course a 4 wire stepper motor can also be driven After inserting the Crowtail Motor Base Shield into Arduino Crowduino the specific method of controllin...

Страница 14: ...s way the car can turn right What will you see 1 Declare the pins to control the speed and direction of rotation of the two motors 2 Setup the pins which are used to control motors as output 3 Create...

Страница 15: ...versa There is also an on board potentiometer to adjust the sensitivity This sensor is a basic and widely used part in applications such as line following cars rotary speed detection auto data logging...

Страница 16: ...e three sensors are blocked by a black object the speed of motor1 and motor2 becomes 0 stopped What will you see 1 Declare the pins of three IR Reflective Sensors and variables to store the state of t...

Страница 17: ...don t get any signal degradation even over long distances The DS18B20 provides 9 to 12 bit configurable temperature readings over a 1 Wire interface so that only one wire and ground needs to be conne...

Страница 18: ...ibrary which is convenient for directly using temperature sensors such as DS18B20 Therefore using these two libraries it will be very convenient for us to use one wire waterproof temperature sensor Im...

Страница 19: ...e RGB LED will light up in different colors like a rainbow What will you see The Crowtail RGB LED module with 4 pcs of WS2812B which is a Chainable Addressable LED Users can control all the LEDs with...

Страница 20: ...lassic v1 not v2 FLORA pixels WS2811 drivers NEO_GRB Pixels are wired for GRB bitstream most NeoPixel products NEO_RGB Pixels are wired for RGB bitstream v1 FLORA pixels not v2 Create instance Adafrui...

Страница 21: ...Call the function we created to show the Text Code overview Crowtail OLED is constructed from the 128 x 64 dot matrix OLED module The display offers high brightness self emission high contrast ratio s...

Страница 22: ...tFont method to select the font we want to display and use the u8g drawStr method to set what position and character we want to draw There are three parameters in the u8g drawStr function The first pa...

Страница 23: ...the libraries of ultrasonic ranging sensor and OLED 2 Create instances of ultrasonic ranging sensor and OLED 3 Create variables to store distance and characters array to change distance using charact...

Страница 24: ...hat we want to create character related distance_ value_temp 5 0 means that we are creating an array that can contain 5 elements Since we used char to declare it it is 5 characters Finally we assign i...

Страница 25: ...tick and store them in two variables 4 Print the x y axes value of joystick in decimal 5 Use if else statement to judge the direction of the joystick and print them Code overview they are actually two...

Страница 26: ...e change in the value of the joystick after changing the position of the joystick So when you have a better idea you can change your value If Statements if logic statement code to be run if the logic...

Страница 27: ...nd initialize it with 90 degrees 4 Read the joystick value 5 If the joystick button is pressed let the servo rotate to 90 degrees 6 If the joystick button is not pressed let the servo rotate to the co...

Страница 28: ...rom fromLow to fromHigh it is also mapped to between toLow and toHigh in equal proportions So here we map the value of pos between 200 and 800 to angle between 0 and 180 For example if the value of jo...

Страница 29: ...c ranging sensor and servo instance object so we can get the distance and make the servo rotate to the angle we want For ultrasonic object there are two parameters inside the parentheses we need to pa...

Страница 30: ...appliance using an Arduino The Crowtail IR Receiver module uses the HS0038B which is miniaturized receivers for infrared remote control systems and it is the standard IR remote control receiver serie...

Страница 31: ...essed for the second time the data LED2 is sent 7 If the collision sensor is pressed for the third time the data OFF is sent Infrared Receiver code 1 Import IR library and declare led buzzer and IR re...

Страница 32: ...iver the data sent by the emitter we have to initialize the IR receiver to tell which pin to obtain the data Therefore we need to enter the pin of the receiver in the parentheses IR Receiver initializ...

Страница 33: ...ta into the EEPROM 5 Call the reading function to read the data from the EEPROM and print Code overview Code usage Micro defines the I2C address of EEPROM The reason why I2C devices can be cascaded is...

Страница 34: ...l change What will you see Arduino Uno Crowduino Uno x1 Crowtail Motor Base Shield x1 Crowtail 3 Axis Digital Accelerometer 16g x1 Crowtail Cable x1 Required Parts The Crowtail 3 Axis Digital Accelero...

Страница 35: ...activity The data format is unsigned so the magnitude of the activity inactivity event is compared with the value is compared with the value in the THRESH_ACT THRESH_INACT register The scale factor is...

Страница 36: ...you see Arduino Uno Crowduino Uno x1 Crowtail Motor Base Shield x1 Crowtail Analog Gyro x1 Crowtail Cable x1 Required Parts The Crowtail Analog Gyro is based on an angular velocity sensor Murata ENC...

Страница 37: ...e float reference_Value 0 double angularVelocity To obtain the reference value is the reason why we need to calibrate the analog gyro in beginning We use for statement to get the analog gyro data 1000...

Страница 38: ...plete connection is as follows Open the P17_Use_Of_Bluetooth with Arduino and upload it Extract the compressed package named HMPCComAssistant_en rar and open the serial port assistant software HMComAs...

Страница 39: ...ived is 1 turn LED on Code overview Code usage Set the baud for serial monitor correspond to our bluetooth module 115200 is the default baud rate for our bluetooth module If we set the wrong baud for...

Страница 40: ...a connector for 3 7V Lithium polymer batteries and built in battery charging You don t need a battery it will run just fine straight from the micro USB connector But if you do have a battery you can t...

Страница 41: ...ferent you can check the port of the board in the port of your computer for Crowtail ESP8266 Node MCU and baud rate there After correctly set click the Connect option on the top of the menu 2 Connect...

Страница 42: ...ck the button on the web page to turn LED and buzzer on or off Use overview Arduino Uno Crowduino Uno x1 Crowtail Motor Base Shield x1 Crowtail OLED x1 Crowtail Ultrasonic Ranging Sensor x1 Micro Spee...

Страница 43: ...n t have to power Crowduino Arduino because the motor base shield will share the power with Crowduino Arduino Open the P19_A_Naughty_Robot with Arduino and upload it If there is nothing in front of th...

Страница 44: ...8g_uint_t y u8g_uint_t w u8g_uint_t h const u8g_pgm_uint8_t bitmap x the abscissa of the upper left corner of the bitmap y the ordinate of the upper left corner of the bitmap w the width of the bitmap...

Страница 45: ...the OUT3 and OUT4 interfaces are connected to the same motor positive and negative poles Be careful not to connect the motor to the interval interface such as OUT1 and OUT3 otherwise the motor will no...

Страница 46: ...received 3 Setup all motor pins as output and initialize the IR receiver 4 Create some motor working functions to be called when different data is received 5 According to the received data the motor...

Страница 47: ......

Отзывы: