AmebaMotors - Use Ameba as Server to Control Motors
Introduction to ambd_arduino/AmebaMotors
ambd_arduino/AmebaMotors is a library which provides API related to controlling motors. Please download the library: ambd_arduino/AmebaMotors And add the library to Ameba: https://www.arduino.cc/en/Guide/Libraries#toc4
Materials
AmebaD [AMB21 / AMB22] x 1
L298N H-Bridge x 1
4-wheel motorcar or 2-wheel motorcar+Universal wheel
Example
Procedure
“Files” -> “Examples” -> “AmebaWiFi” -> “WiFiControlCar”
.
ENA
IN1
IN2
IN3
IN4
ENB
8
9
10
11
12
13
Note
We connect Ameba 5V to L298N +12V to supply power. However, not every L298N accepts 5V power supply, if this does not work, please connect L298N +12V to other power supply (e.g., +12V) and use L298N +5V to supply power to Ameba.
The correct wiring of the motor depends on each model (may be opposite). Please run the test program first, make sure it runs correctly before assembling the motorcar.
For convenience purposes, it’s recommended to use Dupont line to organize the wiring of motors and L298N.
Demo Video
Code Reference
Use WiFi.begin()
to establish WiFi connection.
https://www.arduino.cc/en/Reference/WiFiBegin
To get the information of a WiFi connection:
Use WiFi.SSID()
to get SSID of the current connected network.
https://www.arduino.cc/en/Reference/WiFiSSID
Use WiFi.RSSI()
to get the signal strength of the connection.
https://www.arduino.cc/en/Reference/WiFiRSSI
Use WiFi.localIP()
to get the IP address of Ameba.
https://www.arduino.cc/en/Reference/WiFiLocalIP
Use WiFiServer server()
to create a server that listens on the specified port.
https://www.arduino.cc/en/Reference/WiFiServer
Use server.begin()
to tell the server to begin listening for incoming connections.
https://www.arduino.cc/en/Reference/WiFiServerBegin
Use server.available()
to get a client that is connected to the server and has data available for reading.
https://www.arduino.cc/en/Reference/WiFiServerAvailable
Use client.connected()
to get whether or not the client is connected.
https://www.arduino.cc/en/Reference/WiFiClientConnected
Use client.println()
to print data followed by a carriage return and newline.
https://www.arduino.cc/en/Reference/WiFiClientPrintln
Use client.print()
to print data to the server that a client is connected to.
https://www.arduino.cc/en/Reference/WiFiClientPrint
Use client.available()
to return the number of bytes available for reading.
https://www.arduino.cc/en/Reference/WiFiClientAvailable
Use client.read()
to read the next byte received from the server the client is connected to.
https://www.arduino.cc/en/Reference/WiFiClientRead
Use client.stop()
to disconnect from the server the client is connected to.
https://www.arduino.cc/en/Reference/WiFIClientStop