![]() Source Codeįor this example we need to install the RF24 library. We can note that these modules use the SPI communication, so compared to the previous example, I had the move the Enable A and Enable B pins of the L298N driver to the pins number 2 and 3 of the Arduino board.You can get the NRF24L01 module on the following Amazon link. Now we can move on to the next method, wireless control of the Arduino robot car using the NRF24L01 transceiver modules. available() >= 2) Code language: Arduino ( arduino ) Arduino Robot Car Wireless Control Using NRF24L01 Transceiver Module Code from the Arduino Robot Car // Read the incoming data from the Joystick, or the master Bluetooth device while ( Serial. So here, if the serial has received the 2 bytes, the X and Y values, using the Serial.read() function we will read both of them. We do this because that range, from 0 to 255, can be sent, over the Bluetooth device, as 1 byte which is easier to be accepted on the other side, or at the Arduino robot car. We can note here that the analog values of joystick from 0 to 1023 are converted into a values from 0 to 255 by diving them by 4. We just need to read the X and Y values of the joystick, which actually regulate the speed of the motors, and send them via the serial port to the slave HC-05 Bluetooth device. The code at the master device, or the joystick is quite simple. To do this, the ESP32 would need to be programmed to receive commands via Bluetooth and. It could potentially be used to build a robot car that is controlled via Bluetooth from a remote device. write(xAxis/ 4) // Dividing by 4 for converting from 0 - 1023 to 0 - 256, (1 byte) range Serial. The ESP32 is a microcontroller that is often used to build Internet of Things (IoT) devices, as it has built-in WiFi and Bluetooth capabilities. YAxis = analogRead(A1) // Read Joysticks Y-axis // Send the values via the serial port to the slave HC-05 Bluetooth device Serial. XAxis = analogRead(A0) // Read Joysticks X-axis begin( 38400) // Default communication rate of the Bluetooth module We will use the same code from the previous tutorial, where we control the Arduino robot car directly using the joystick, and we will make some modifications to it.Īrduino Robot Car Wireless Control using the HC-05 Bluetoothīy Dejan Nedelkovski, */ int xAxis, yAxis As an Amazon Associate I earn from qualifying purchases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |