Introduction: ESP8266 and Visuino: WiFi Remote Control Smart Car Robot With Wii Nunchuck

Smart Car sets when combined with L298N Motor Driver Modules, offer one of the easiest ways to make robot cars. I already made an Instructable on how you can control Smart Car with Arduino and Joystick. It is more interesting however if we can control the Car remotely. The ESP8266 modules are great low cost stand alone controllers with built in Wi-Fi, and are well fit for remotely controlling the robot car.

In this Instructable I will show you how easy it is to remotely control a Smart Car with a Wii Nunchuck Controller over WiFi with the help of 2 NodeMCU ESP8266 modules and Visuino.

Step 1: Components

  1. One Smart Car chassis with 2 DC motors, gears and wheels
  2. 2 NodeMCU ESP8266 boards (I used both NodeMCU 0.9, and NodeMCU 1.0 versions, but any other combination, or even stand alone ESP-12 will work)
  3. One L298N Dual Motor Driver Module
  4. One Wii Nunchuck Controller
  5. 2 USB Power supplies with USB Cables (I used a USB Power Bank for the car, and an USB Adapter(Picture 2) for the remote but any other combination will work)
  6. 4 Female-

    Female jumper wires

  7. 6 Female-Male jumper wires

Step 2: Connect the Motors to the L298N Motor Driver Board

  1. Connect the wires from one of the motors to the OUT1 and OUT2 Motor Control pins of the L298N Motor Driver Module (Picture 1)
  2. Connect the wires from one of the motors to the OUT3 and OUT4 Motor Control pins of the L298N Motor Driver Module (Picture 2)
  3. Pictures 3 shows the connected wires to the L298N Motor Driver Module
  4. Picture 4 shows the other end of the wires connected to the Motors and the 0.1uF anti-sparkingcapacitors soldered to the Motors as shown in this Instructable

Step 3: Connect Power to the L298N Motor Driver Board

  1. Connect Male end of a Female-Male Power wire(Red wire) to the +12V Power Pin of the L298N Motor Driver Module (Picture 1 and 2)
  2. Connect Male end of a Female-Male Ground wire(Black wire) to the Ground Pin of theL298N Motor Driver Module (Picture 1 and 2)
  3. Connect the other end of the Ground wire(Black wire) to the Ground Pin of the ESP8266 NodeMCU Module (Picture 3)
  4. Connect the other end of the Power wire(Red wire) to the 5V(Called "Vin" in version 1.0) Power Pin of the ESP8266 NodeMCU Module (Picture 3)
  5. Picture 4 shows where are the Ground, 5V(Vin) Power, and Digital 2 pins of the NodeMCU 0.9

Step 4: Connect the L298N Motor Driver Board Control Pins to the ESP8266 NodeMCU

  1. Leave the ENA and ENB jumpers on the L298N Motor Driver Module (Picture 1)
  2. Connect the Female end of a Female-Male wire(Control 1)(Purple wire) to the IN1 pin of the L298N Motor Driver Module (Picture 1)
  3. Connect the Female end of a Female-Male wire(Control 2)(Blue wire) to the IN2 pin of theL298N Motor Driver Module (Picture 1)
  4. Connect the Female end of a Female-Male wire(Control 3)(Green wire) to the IN3 pin of theL298N Motor Driver Module (Picture 1)
  5. Connect the Female end of a Female-Male wire(Control 4)(Yellow wire) to the IN4 pin of the L298N Motor Driver Module (Picture 1)
  6. Connect the other end of the Control 1 wire(Purple wire) to the Digital 2 Pin of the ESP8266 NodeMCU Module (Picture 2)
  7. Connect the other end of the Control 2 wire(Blue wire) to the Digital 3 Pin of the ESP8266 NodeMCU ModulePicture 2)
  8. Connect the other end of the Control 3 wire(Green wire) to the Digital 4 Pin of the ESP8266 NodeMCU Module(Picture 2)
  9. Connect the other end of the Control 4 wire(Yellow wire) to the Digital 5 Pin of the ESP8266 NodeMCU Module (Picture 2)
  10. Picture 4 shows in Red the NodeMCU 0.9pins that ware connected in this step. In Blue are shown the connections done in the previous step

Step 5: Add Power and Secure the Lose Components to the Car Chassis

  1. Add a USB power source (In my case a rechargeable USB power bank) (Picture 1)
  2. Use straps, rubber bands, screws or any other convenient ways to secure the wires and boards to the chassis (Pictures 1 and 2)

Step 6: Connect Jumper Wires to the Wii Nunchuck Controller

The Wii Nunchuck Controller uses I2C interface. Picture 1 shows the I2C pins of the Wii Nunchuck controller connector. The Connector is not designed to connect wires to it, but to be plunged into another specially designed connector, however there is an easy way to connect Male jumper wires into it. The connector has small openings next to the pins (Picture 2), and by inserting the pin of a male jumper wire (Picture 3), we can make a connection. There are also specially designed adapters for Wii Nunchuck Controllers, but I don't have one at the moment, so I inserted the wires directly.

  1. Place the connector with its long flat side down as shown on Pictures 1 and 2
  2. Insert the Male end of one of the Male-Female jumper wires(Red wire) into the small opening bellow the Bottom Left (3.3V Power) pin (Picture 3)
  3. Insert the Male end of another Male-Female jumper wire(Green wire) into the small opening bellow the Bottom Right (SDA/Data) pin (Picture 4)
  4. Insert the Male end of another Male-Female jumper wire(Yellow wire) into the small opening above the Top Left (SCL/Clock) pin (Picture 5)
  5. Insert the Male end of another Male-Female jumper wire(Black wire) into the small opening above the Top Right (GND/Ground) pin (Picture 6)

Step 7: Connect the Wii Nunchuck to the Second ESP8266 NodeMCU

  1. Connect the other end of the SCL wire(Yellow wire) to SCL/Digital pin 1 of the ESP8266 NodeMCU board (Picture 1)
  2. Connect the other end of the SDA wire(Green wire) to SDA/Digital pin 2 of the ESP8266 NodeMCU board (Picture 1)
  3. Connect the other end of the Ground wire(Black wire) to the Ground pin of the ESP8266 NodeMCUboard (Picture 2)
  4. Connect the other end of the Power wire(Red wire) to the 3.3V Power pin of the ESP8266 NodeMCUboard (Picture 2)
  5. Picture 3 shows where are the Ground, 3.3V Power, Digital 1, and Digital 2 pins of the NodeMCU 1.0

Step 8: Start Visuino, and Select the ESP8266 Board Type

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6.

Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

If you have not done follow the steps in this Instructable to setup the Arduino IDE to program ESP 8266!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuinoas shown in the first picture
  2. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  3. When the dialog appears, select "NodeMCU ESP-12" as shown on Picture 2

Step 9: In Visuino: Add and Connect Motor Driver Bridge Component

  1. Type "motor" in the Filter box of the Component Toolbox then select the "Dual DC Motor Driver 2 Pin Bridge (L9110S, L298N)" component (Picture 1), and drop it in the design area
  2. Since we left the ENA and ENB jumpers on the L298N Motor Driver module, we will control it with only 2 pins per motor. Visuino also includes a component to control it with the 3 pins, if the jumpers are disconnected, but this is not necessary
    • Connect the "Direction(B)" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 2 ]" channel of the “NodeMCU ESP-12” component (Picture 1)
    • Connect the "Speed(A)" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 3 ]" channel of the “NodeMCU ESP-12” component (Picture 2)
    • Connect the "Direction(B)" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 4 ]" channel of the “NodeMCU ESP-12” component (Picture 3)
    • Connect the "Speed(A)" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 5 ]" channel of the “NodeMCU ESP-12” component (Picture 4)

    Step 10: In Visuino: Setup the Module As Access Point

    1. In the Object Inspector, expand the "Modules" property, then the "WiFi" sub property, then the "AccessPoint" sub property (Picture 1)
    2. Set the value of the "SSID" sub property of the "AccessPoint", to “SmartCar1” (Picture 1)

    We will assign a fixed IP address of 200.200.200.200 so we can easily connect to the module by IP:

    1. In the Object Inspector, expand the "Config" sub property of the "AccessPoint" property (Picture 2)
    2. Set the value of the “Enabled” sub property of the Config to “True” (Picture 2)
    3. Set the value of the “IP” sub property to "200.200.200.200" (Picture 3)

    Step 11: In Visuino: Add an UDP Socket for the Communication

    Next we need to add an UDP socket for the communication.

    1. In the Object Inspector, click on the "..." button next to the value of the "Sockets" sub property of the "WiFi" property (Picture 1)
    2. In the Sockets editor select “UDP Socket”, and then click on the "+" button (Picture 2)
    3. In the Object Inspector set the value of the “Port” to “8888” (Picture 4)

    Step 12: In Visuino: Add Split Structure Component, and Add Analog Channels to It

    The Remote controller needs to send the speeds of the left and right motors. The simplest way is to send them in binary floating point form as a structure. We need to decode it properly. For this we need a “Split Structure” component with 2 “Analog” elements in it.

    1. Type "split" in the Filter box of the Component Toolbox then select the "Split Structure" component (Picture 1), and drop it in the design area
    2. Click on the "Tools" button (Picture 2) to open the Elements editor (Picture 3)
    3. In the "Elements" editor select the “Analog” element, and then click 2 times on the "+" button (Picture 3) to add 2 Analog elements (Picture 4)
    4. Close the Elements editor

    Step 13: In Visuino: Connect the Split Structure Component

    1. Connect the "Out" pin of the "Elements.Analog1" of the SplitStructure1 component to the "In" pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component (Picture 1)
    2. Connect the "Out" pin of the "Elements.Analog2" of the SplitStructure1 component to the "In" pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component (Picture 2)
    3. Connect the “Out” pin of the “Modules.WiFi.Sockets.UDPSocket1” of the “NodeMCU ESP-12” component, to the “In” pin of the SplitStructure1 component (Picture 3)

    The Smart Car programming part of the project is completed!

    On Picture 4 you can see the complete Visuino Diagram.

    Step 14: Generate, Compile, and Upload the ESP8266 Code for the Smart Car

    1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
    2. Connect the first NodeMCU module (The one on the Smart Car) with USB cable to the computer
    3. Select the board type and serial port as I have shown you in this Instructable
    4. Make sure you have installed the latest staging version of the ESP support! The stable release does not have some of the latest features, and you will have errors when you try to compile!
    5. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

    Step 15: in Visuino: Select the ESP8266 Board Type, and Configure It to Connect to the Access Point

    Now lets program the Wii Nunchuck Remote Control module.

    1. Start new project.
    2. Click on the "Tools" button on the Arduino component, and when the dialog appears, select "NodeMCU ESP-12" as you did in Step 8 for the Smart Car module

    Next we need to configure the module to connect to the Access Point of the Smart Car module, and use a fixed IP Address of 200.200.200.100 so it can be on the same 200.200.200.X subnet.

    1. In the Object Inspector, expand the “Modules” property, then the “WiFi” sub property, then the “AccessPoints” sub property, and click on the "..." button next to its value (Picture 1)
    2. In the "AccessPoins" editor, select “WiFi Access Point”, and then click on the "+" button on the left, to add the access point (Picture 2)
    3. In the Object Inspector, set the value of the "SSID" property to “SmartCar1” (Picture 3)
    4. In the Object Inspector, expand the “Config” property, and set the value of the “Enabled” sub property to “True” (Picture 4)
    5. In the Object Inspector, set the value of the “IP” sub property to “200.200.200.100” (Picture 5)

    Step 16: In Visuino: Add an UDP Socket for the Communication

    Next we need to add an UDP socket for the communication.

    1. In the Object Inspector, click on the "..." button next to the value of the "Sockets" sub property of the "WiFi" property (Picture 1)
    2. In the Sockets editor select “UDP Socket” on the right, and then click on the "+" button on the left (Picture 2)
    3. In the Object Inspector, set the value “RemoteIPAddress” property to “200.200.200.200” (Picture 3) – this is the fixed IP address that we will assigned to the Smart Car ESP8266 module
    4. In the Object Inspector set the value of the “RemotePort” to “8888” (Picture 4)
    5. Close the "Sockets" dialog

    Step 17: In Visuino: Add and Connect Wii Nunchuck Component

    1. Type "wii" in the Filter box of the Component Toolbox then select the "Wii Nunchuck Controller" component (Picture 1), and drop it in the design area
    2. Connect the "Out" pin of the WiiNunchuck1 component (Picture 2) to the to the "In" pin of the I2C channel of the “NodeMCU ESP-12” component (Picture 3)

    Step 18: In Visuino: Add, Connect and Configure Map Range Component

    The Wii Nunchuck Joystick does not produce a full range of values from 0.0 to 1.0. Instead the values are from around 0.14 to around 0.89 . The values may differ a bit from controller to controller. To convert the Nunchuck "Y" range into a full range we can use Map Range component. We can also correct the "X" range, but that is not necessary, as for turning a full range is not so important as for forward/reverse speed.

    1. Type "map" in the Filter box of the Component Toolbox then select the "Map Range" component (Picture 1), and drop it in the design area
    2. Connect the "Y" pin of the "Stick" group of the WiiNunchuck1 component to the "In" pin of the MapRange1 component (Picture 2)
    3. Select the MapRange1 component (Picture 3)
    4. In the Object Inspector expand the "InputRange" property (Picture 3)
    5. In the Object Inspector set the value of the "Max" sub-property to "0.89" (Picture 3)
    6. In the Object Inspector set the value of the "Min" sub-property to "0.14" (Picture 4)

    Step 19: In Visuino: Add and Connect a Steering Differential Component

    1. Type "steer" in the Filter box of the Component Toolbox then select the "Steering Differential" component (Picture 1), and drop it in the design area.
      This component will calculate the speed of the left and right motors based on the Speed and Direction from the Joystick (X and Y control)
    2. Connect the "X" pin of the "Stick" group of the WiiNunchuck1 component to the "Direction" input pin of the Steering1 component (Picture 2)
    3. Connect the "Out" pin of the MapRange1 component to the "Speed" input pin of the Steering1 component (Picture 3)

    Step 20: In Visuino: Add Make Structure Component, and Add Analog Channels to It

    We need to send a packet of 2 analog values for the speeds of the 2 motors. To do this we will make a structure with 2 analog values and will send it over the UDP socket.

    1. Type "make" in the Filter box of the Component Toolbox then select the "Make Structure" component (Picture 1), and drop it in the design area
    2. Click on the "Tools" button (Picture 2) to open the "Elements" editor (Picture 3)
    3. In the "Elements" editor select the “Analog” element, and then click 2 times on the "+" button (Picture 3) to add 2 Analog elements (Picture 4)
    4. Close the "Elements" editor.

    Step 21: In Visuino: Connect the Make Structure Component

    1. Connect the "Left" pin of the "Motors" pin list of the Steering1 component to the "In" pin of he “Elements.Analog1” element of the MakeStructure1 component (Picture 1)
    2. Connect the "Right" pin of the "Motors" pin list of the Steering1 component to the "In" pin of the "Elements.Analog2" channel of the MakeStructure1 component (Picture 2)
    3. Connect the “Out” pin of the MakeStructure1 component to the “In” pin of the "Modules.WiFi.Sockets.UDPSocket1” of the “NodeMCU ESP-12” component (Picture 3)

    Step 22: Generate, Compile, and Upload the ESP8266 Code for the Remote

    1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
    2. Connect the second NodeMCU module (The one with the Wii Nunchuck Controller) with USB cable to the computer
    3. Select the board type and serial port as I have shown you in this Inctructable
    4. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

    Step 23: And Play...

    At this point you can already start playing with the Smart Car.

    If you connect the Power to the car and the remote, you can use the Joystick of the Wii Nunchuck to control the car by moving the Joystick forward and backward the car will move in the Forward or Backward direction, and moving the Joystick left and right will make the car turn left and right.

    If the car is not moving as expected, you may need to swap the wires controlling the motors connected in Step 3 to make them rotate in the proper direction.

    On the Picture you can see the complete Visuino diagram.

    If this is enough, you can ignore the following steps, however if you also want to be able to control the car with the tilt of the Wii Nunchuck, continue with the next step.

    Step 24: In Visuino: Add and Connect Analog Toggle Switch Component

    We want to use the "Z" key on the Wii Nunchuck to switch between the Joystick and the Tilt control. To switch the controls we will need to add 2 Analog switches:

    1. Type "switch" in the Filter box of the Component Toolbox then select the "Analog Toggle Switch" component (Picture 1), and drop two of them in the design area
    2. Connect the "X" pin of the "Stick" group of the WiiNunchuck1 component to the "False" input pin of the AnalogToggleSwitch1 component (Picture 2)
    3. Connect the "Out" pin of the AnalogToggleSwitch1 component to the "Direction" input pin of the Steering1 component (Picture 3)
    4. Connect the "Out" pin of the MapRange1 component to the "False" input pin of the AnalogToggleSwitch2 component (Picture 4)
    5. Connect the "Out" pin of the AnalogToggleSwitch2 component to the "Speed" input pin of the Steering1 component (Picture 5)

    Step 25: In Visuino: Add and Connect Two Map Range Components for the Tilt

    The Wii Nunchuck Tilt does not produce a full range of values from 0.0 to 1.0 similar to the way the Joystick works. To convert the Nunchuck "X" and "Y" tilt ranges into full ranges we can use Map Range components.

    1. Type "map" in the Filter box of the Component Toolbox then select the "Map Range" component (Picture 1), and drop two of them in the design area
    2. Connect the "X" pin of the "Stick" group of the WiiNunchuck1 component to the "In" pin of the MapRange2 component (Picture 2)
    3. Connect the "Out" pin of the MapRange2 component to the "True" input pin of the AnalogToggleSwitch1 component (Picture 3)
    4. Connect the "Y" pin of the "Stick" group of the WiiNunchuck1 component to the "In" pin of the MapRange3 component (Picture 4)
    5. Connect the "Out" pin of the MapRange2 component to the "True" input pin of the AnalogToggleSwitch2 component (Picture 5)

    Step 26: In Visuino: Configure the Map Range Components for the Tilt

    The mapping values in this step are based on my Nunchuck controller. You may need to use slightly different values for your controller.

    1. Select the MapRange1 component (Picture 1)
    2. In the Object Inspector expand the "InputRange" property (Picture 1)
    3. In the Object Inspector set the value of the "Max" sub-property to "0.6" (Picture 1)
    4. In the Object Inspector set the value of the "Min" sub-property to "0.3" (Picture 2)
    5. Select the MapRange2 component (Picture 3)
    6. In the Object Inspector expand the "InputRange" property (Picture 3)
    7. In the Object Inspector set the value of the "Max" sub-property to "0.7" (Picture 3)
    8. In the Object Inspector set the value of the "Min" sub-property to "0.19" (Picture 4)

    Step 27: In Visuino: Add and Connect Edge Detect and T Flip-Flop Components

    To implement the Toggle functionality, we need to use a Flip-Flop. The most convenient for this purpose is the Toggle(T)-FlipFlop.

    To control the FlipFlop we need to generate event only when the button is pressed. For this we need an edge detector, to detect the change of the digital level from False to True

    1. Type "edge" in the Filter box of the Component Toolbox then select the "Detect Edge" component (Picture 1), and drop it in the design area
    2. Type "flip" in the Filter box of the Component Toolbox then select the "Toggle(T) Flip-Flop" component (Picture 2), and drop it in the design area
    3. Connect the "Z" pin of the "Button" group of the WiiNunchuck1 component to the "In" pin of the DetectEdge1 (Picture 3)
    4. Connect the "Out" pin of the DetectEdge1 to the "In" pin of the Flip-Flop(Picture 4)
    5. Connect the "Out" pin of the TFlipFlop1 to the "Select" input pin of the AnalogToggleSwitch2 component (Picture 5)
    6. Connect the "Out" pin of the TFlipFlop1 to the "Select" input pin of the AnalogToggleSwitch1 component (Picture 6)

    Step 28: Generate, Compile, and Upload the ESP8266 Code for the Remote

    1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
    2. Connect the second NodeMCU module (The one with the Wii Nunchuck Controller) with USB cable to the computer
    3. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

    Step 29: And Play...

    Congratulations! You have a full remote control over your robot.

    The Video shows the connected and powered up Smart Car.

    If you power up the Car and the Remote, you can use the Wii Nunchuck Joystick to control the car by moving the Joystick forward and backward the car will move in the Forward or Backward direction, and moving the Joystick left and right will make the car turn left and right.

    If you press the "Z" button on the Wii Nunchuck, you will switch to controlling the car with the tilt of the controller as seen in the video.

    Pressing "Z" again, switches back to Joystick control.

    On the Picture you can see the complete Visuino diagram.

    Also attached are the Visuino projects, that I created for this Instructable. You can download and open them in Visuino: https://www.visuino.com

    • WiiNunchuckWiFiSmartCarInstructable.owarduino is the project for the Smart Car module

    • WiiNunchuckWiFiSmartCarRemote_Step1_Instructable.owarduino is the project for Wii remote control module with Joystick control only (before we added the Tilt control)

    • WiiNunchuckWiFiSmartCarRemoteInstructable.owarduino is the final version of the project for the Wii remote control module

    Comments

    author
    LuisP140 made it!(author)2016-08-25

    is really necessary to use both ESP8266? Can we use just one for remote control and dc motors? I think esp has enough GPIO's for these purposes

    author
    BoianM made it!(author)2017-02-15

    You can use only one ESP8266, bit then it will not be Wi-Fi remote controlled, but will be controlled with the cable from the Wii ;-)

    author
    KurtRoesener made it!(author)2017-02-15

    Hi, if you want to drive the car with just wired control you can use this Instructable:

    https://www.instructables.com/id/Arduino-Uno-and-Visuino-Control-Smart-Car-Robot-Wi/

    author
    BoianM made it!(author)2016-08-25

    So how you will send the commands to the ESP8266 ? I use one ESP to send commands to the other over WiFi. If you use a computer, or mobile for that, sure, you can use single ESP, the other ESP will be replaced by the computer or the mobile - both more expensive than the ESP module used in this project, and less fun IMHO ;-)

    author
    TristanG14 made it!(author)2016-11-15

    Hi, I have a project which would ideally use RF to control the car as it is meant for running outdoors - I need the visuino and circuit diagrams for this as I am unsure how to connect the arduino to the reciever and the nunchuck to the transmitter. A quick reply would be appreciated. Thanks!

    author
    TristanG14 made it!(author)2016-11-22

    Never mind, I found out that it will be easier to buy a wireless nunchuck instead of going through the pain of making a wired nunchuck wireless without the use of Wi-Fi. This diagram shows how you can link up the receiver of the wireless nunchuck with the Arduino. It uses the same techniques as the diagram in KekkoF's question however, I have chosen to keep the Z button and the accelerometer. I hope this is of help to anyone:

    Capture.PNG
    author
    BoianM made it!(author)2016-11-22

    Cool! :-) Post a picture of the completed project :-) Will be cool to see it ;-)

    author
    TristanG14 made it!(author)2016-11-22

    One question - how would I wire up the Wii nunchuck to the Arduino / or wherever it goes?

    author
    TristanG14 made it!(author)2016-11-22

    Actually, I think I might need the entire circuit diagram - getting confused between the visuino and actual wiring...

    author
    BoianM made it!(author)2016-11-22

    The Wii is I2C device, so you connect it like any other I2C as example this:
    https://www.instructables.com/id/Arduino-Nano-DS130...

    Analog Pin 4 and 5

    author
    TristanG14 made it!(author)2016-11-22

    Ok, I think I've got the hang of it now, would this work or does it need tweaking?

    Capture.PNG
    author
    BoianM made it!(author)2016-11-23

    I think you need to disconnect the Clock. Otherwise looks fine as far as I can tell. The Clock is optional, and in yor case will make it worse, so disconnect it.

    author
    TristanG14 made it!(author)2016-11-26

    But then how would the nunchuck interact with the motor driver? Btw, I am only using 1 Arduino nano - not 2 - maybe we are confusing things? To clarify, I thought my finished circuit would look like this (ignore the left half of the circuit - I am putting on a Bluetooth speaker but at the moment it is irrelevant - The circuit to the right of the two speakers is what I thought the circuit would look like)

    Circuit.jpg
    author
    BoianM made it!(author)2016-11-26

    The code generated by Visuino instructs the Wii to control the motor driver. You can see it from the Visuino diagram ;-)

    author
    TristanG14 made it!(author)2016-11-26

    Ok got it! I will connect the Wii nunchuck to D4, D5, GND and 3V3 and the Motor Driver to D6, D7, D8 and D9 - does that sound about right? all I will need to do then is to adjust the visuino code to make it so that the motor driver is on the respective pins.

    author
    BoianM made it!(author)2016-11-26

    Actually the Wii goes to A4 and A5 not D4, and 5. The A4/5 are the I2C pins! You already showed a good Visuino diagram. Only disconnect the Clock for the Wii, othewise seems good.

    author
    TristanG14 made it!(author)2017-01-19

    Hi BoianM,

    I have all the circuitry in place and all the code on the Arduino however, once I add the power source, the motors just keep moving forward, no matter what I do with the Wii Nunchuck - Here is the Diagram:

    Very close to completing the product. Thanks for the help :)

    Screenshot of visuino file.png
    author
    BoianM made it!(author)2017-01-19

    Hi TristanG14,

    Start by connecting each part one by one to the serial and checking what the values are ;-) First connect as example the X of the Wii to serial, and see if it works, then the Y, then do the same for the output of the analog toggle switch etc. ;-) . This way you will discover where the values look wrong ;-)

    author
    TristanG14 made it!(author)2017-01-20

    And how would I view the serial? I have so far tried uploading the code to the Arduino then using the built in the terminal on Visuino, however, I'm just getting blank lines.

    author
    BoianM made it!(author)2017-01-20

    You can use the Visuino Terminal, or the Arduino IDE terminal. If you connect as example the "X" output of the controller in Visuino to the In pin of the Serial, and program the Arduino, you should be able to see the values ;-)

    author
    TristanG14 made it!(author)2017-02-08

    Hi Boian

    Sorry for the late reply, and things are well on the way to completion, however, when I used the terminal and read the serial, it only received 8 values before it stopped receiving anything - no matter what I did. In a nutshell, every time I reset the Arduino, it reads the Wii Nunchuck for about half a second, then stops receiving anything.


    In visuino the Wii Nunchuck controller is:

    Enabled,

    Read delay: 100

    and the Arduino Nano is:

    Analog input ref: Default

    I2C Address: 0

    I2C Is Slave: False


    Thanks!

    Tristan

    author
    TristanG14 made it!(author)2016-11-27

    Whoops - typo - anyway thank you for your help and I will show you the finished project once I am done.

    author
    TristanG14 made it!(author)2016-11-22

    And should I put the data pin from the nunchuck onto D0?

    author
    BoianM made it!(author)2016-11-23

    On UNO and Nano the I2C data goes to Analog Pin 4, and the Clock goes to Analog Pin 5 as I show in the Instructable ;-)

    https://www.instructables.com/id/Arduino-Nano-DS130...

    author
    TristanG14 made it!(author)2016-11-22

    But should I connect the motor driver on the same pins? Or different?

    author
    BoianM made it!(author)2016-11-22

    He seems to have connected the motor driver as in this tutorial:

    https://www.instructables.com/id/Arduino-Uno-and-Vi...

    You can do the same connections.

    author
    BoianM made it!(author)2016-11-22

    Actually your project is probably a really good candidate for an Instructable of it own :-) If you need help making one, please let me know ;-)

    author
    TristanG14 made it!(author)2016-11-22

    By the way, the Arduino Nano can be replace with the Arduino UNO + others :)

    author
    FrancM made it!(author)2017-01-15

    Hello Boian,

    Did you have any problems powering the car with the powerbank? I've read elsewhere that powerbanks have an auto switch off function that make them unreliable when used with arduino.

    author
    BoianM made it!(author)2017-01-15

    Hi FrancM,
    My particular power bank worked quite well actually. I did few projects with it, and I use it a lot in my testing, but I have never tested with other power banks :-( . Maybe my one is just exception...

    Cheers,
    Boian

    author
    KekkoF made it!(author)2016-11-05

    hi i have a similar project, i need the sketch for control two motor dc with arduino +l298n+ wiinunchuk wire no wireless , and with only joystick ... you can help me ????

    author
    BoianM made it!(author)2016-11-05

    Here is a Visuino diagram that will do this :-) It should be easy to make further changes if needed.

    WiiMotorsControl.png
    author
    KaustavN made it!(author)2016-05-12

    I had a question regarding the connections between the nodemcu and the motor driver. You connected the +12V pin of the motor driver (the one for the driving the motor itself) to the 5V input of the nodemcu. Assuming that the motor is of 5V, the motor driver still needs +5V on the +5V pin on the motor driver which you didn't provide. I know that if the power supplied to the +12V pin of the driver (for driving the motor) is 12V or more, the +5V of the driver automatically becomes high. But here only 5V is provided to the +12V pin of the board. So where does the +5V pin of the motor driver get its power from?

    author
    BoianM made it!(author)2016-05-12

    The 5V pin on the NodeMCU is directly connected to the 5V of the USB connector. When I connect the USB power bank, it will power both the NodeMCU and the Motor Driver ;-)

    author
    KaustavN made it!(author)2016-05-13

    Yeah but doesn't the motor driver require 2 separate power supplies? 1 for the motor power pin ( the +12V pin) and one for powering the driver board itself (the +5V pin ) ? You only connected the power for driving the motor here didn't you? Where is the driver board itself being powered from?

    author
    BoianM made it!(author)2016-05-13

    You are right, I am powering it with 5 V and it goes through the internal regulator and provides probably somewhat lower voltage to the bridge. It is enough to power it, but probably not that good. A better solution will be to remove the 5V jumper on the bridge, and supply the 5V separately.

    author
    davew89 made it!(author)2016-04-01

    hi having a problem uploading sketches have tryed version 1.6.6 and 1.6.5 but keep getting errors what libaries do i need to make sure are installed please

    author
    BoianM made it!(author)2016-04-01

    The best is to use 1.6.7. This project does not use any external libraries. The only thing you need is the ESP8266 board support as shown in this Instructable:

    https://www.instructables.com/id/Setting-Up-the-Arduino-IDE-to-Program-ESP8266/

    author
    davew89 made it!(author)2016-04-01

    cool got it uploaded now one motor on all time lol and advice please

    author
    BoianM made it!(author)2016-04-01

    Cool! :-) Post some pictures when you get it running :-)

    author
    Murray+Locksmith made it!(author)2016-03-03

    Excellent sense of humour.