<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <link href="https://funduinoshop.com/en/blog/projects/?sAtom=1" rel="self" type="application/atom+xml" />
    <author>
        <name>Funduinoshop</name>
    </author>
    <title>Blog / Atom Feed</title>
    <id>https://funduinoshop.com/en/blog/projects/?sRss=1</id>
    <updated>2026-04-09T12:45:53+02:00</updated>
    
        <entry>
            <title type="text">Build RC Car for Arduino: Autonomous vehicle - part 3</title>
            <id>https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-3</id>
            <link href="https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-3"/>
            <summary type="html">
                <![CDATA[
                
                                            Welcome to the third installment of our blog series on robot cars. In the first part, we learned the basics for the basic vehicle. In the second part, we developed a universal code system that we can use to set driving levels of the robot car....
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                  Understanding the mobility of the future with robot cars, part 3  
 Welcome to the third installment of our blog series on robotic cars. In the   first part  &amp;nbsp;we learned about the basics of the basic vehicle. In the   second part  &amp;nbsp;we developed a universal code system to define driving levels of the robot car and realized a simple remote control with an infrared remote control. Due to the physical limitations of this remote control, in this episode I would like to show the transmission of driving instructions using Bluetooth, e.g. from a smartphone to the BT receiver HC-05. Bluetooth is a 2.4GHz radio signal with short range. Safe up to about 10m and interference free in sunlight. 
 The Bluetooth module HC-05 is actually a  transceiver=transmitter + receiver . However, we use it only as a receiver, for sending the driving instructions we use a Bluetooth APP on the Android smartphone (because of the special way of Apple with Bluetooth it does not work with an iPhone). In principle, it is also possible to build a Bluetooth remote control with the HC-05; however, this requires a second HC-05, more micro controller and an input device (joystick controller). 
 &amp;nbsp;  
  Of the six pins on the HC-05 module, only four are needed: VCC (5V) and GND for the module&#039;s power supply, and RXD and TXD for connection to two pins of the microcontroller where SoftwareSerial is set up. However, you can&#039;t ignore the inscription LEVEL: 3.3V in order not to damage the module. On our microcontroller with 5V logic, we need a voltage divider from 5V to 3.3V at least for the RXD pin, so resistors of 1 kOhm and 2.2 kOhm, for example. 
 The schematic: HC-05 module on the microcontroller    
 The AT commands of the HC-05 module for Arduino microcontroller 
 To the left of the connector marked Key there is a small button, which is important for the configuration. When this button is pressed during power-on, we enter the AT command mode (the LED flashes slowly in a 2s rhythm), where we use so-called AT commands (for Attention, Achtung) to make the settings. For this we use a modified example program, where the usual serial port is connected to the Serial Monitor of the Arduino IDE and the HC-05 via SoftwareSerial. 
  /*
  Software serial multiple serial test
 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device) // voltage divider!
 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart&#039;s example
 This example code is in the public domain.
 */ 
  #include   &amp;lt;SoftwareSerial.h&amp;gt;  
 SoftwareSerial  BTSerial (10 ,  11 );  // RX, TX // mySerial changed to BTSerial 
 char  c= &#039; &#039; ;  // Declaration of variable for transmission 

 void   setup () {
  // Open serial communications and wait for port to open: 
  Serial  .begin  (9600 );  // Baud rate changed to 9600 
  Serial  .println ( &quot;Serial started!&quot; );

  // set the data rate for the SoftwareSerial port 
  BTSerial .begin  (38400 );  // Baud rate for BT 38400 
  Serial  .println ( &quot;BTSerial started! &quot;);
}

 void   loop () {  // run over and over 
  if  (BTSerial .available ()) {
    c=BTSerial .read ();
    Serial  .write (c);
  }
  if  (Serial  .available ()) {
    c=Serial  .read ();
    BTSerial .write (c);
    Serial  .write (c);  // re-transmission of input in Serial Monitor 
  }
} 
 The main AT commands are used in the following figure. The remote station, the HC-05, sends a response if necessary and acknowledges with OK. 
 We are mainly interested in the name and the HEX address in order to uniquely identify the module later on the smartphone. The AT commands are entered into the serial monitor of the microcontroller. In the following picture you can see the serial monitor of the Arduino IDE. 
 If you want, you can change the default password 1234 with &quot;AT+PSWD=xxxx &quot;, where x stands for a digit from 0 to 9. Afterwards check with &quot;AT+PSWD? &quot; if the input was successful.    After finishing the inputs the module is disconnected from power for a short time. After switching on again without pressing a button, the HC-05 module is in standard mode. The LED flashes quickly (approx. 5 times/s). 
 Modifications of the RC-Car: different Motorshield 
 Now to the Robot Car. After we used the Motor Controller V2 last time, which only needs the two I2C connectors SDA=A4 and SCL=A5 for the control signals, this time I want to introduce the older Motor Controller V1, which blocks a lot of digital pins, but can often be bought for a bargain price.     I also modified this Motorshield a bit to get access for sensors and radio receivers. On the digital pin side, there is only one pin that can be accessed using an angled connector: Pin 2. This is good for those who want to connect the IR receiver here. There are more possibilities for expansion on the other side, where you can access all analog inputs as well as the power supply with the help of female connectors (also called female headers). 
 Since all analog inputs can also be used as digital inputs or outputs, we have the possibility to connect our radio receivers here. This works wonderfully with the 433 MHz transceiver HC-12 (see next episode), but for the BT receiver HC-05 only with restrictions. First, we can&#039;t connect the RXD pin directly, we need the voltage divider, and second, the pins don&#039;t provide enough current to power the module on those pins. 
 On the following picture you can see a small adapter we made ourselves, which supplies the HC-05 with 5V and ground from the corresponding pins, connects TXD directly to RX of the SoftwareSerial interface A1 =D15 and RXD via the voltage divider to A2 = D16.   
 The circuit diagram: HC-05 module with L293D Motorshield on Arduino microcontroller     
 The circuit can of course also be realized on a mini breadboard with jumper cables. 
 Like last time, the code for the driving instructions is increased or decreased by pressing a button; this time only not with IR remote control, but with the touch function in the smartphone APP and the Bluetooth query via SoftwareSerial. 
 Pairing the HC-05 Bluetooth Module with an Android Application (APP) 
 Before the APP can connect to the Robot Car, we need to pair it with the Bluetooth module in the settings. This should be quite easy, because we have previously used the AT commands to get the name and HEX address of the HC-05. 
 Once the pairing has worked and a suitable BT app has been installed, it can be launched and set up. By tapping on the magnifying glass in the left picture, suitable devices are displayed. We tap on the HC-05 and get the message &quot;connected&quot;. The app I used offers several interfaces for operation (middle image). I decided to use the game controller. On the middle picture on the top right there are two arrows forming a small circle. Please tap here if the connection is lost. 
 On the right picture are the buttons of a game controller. Before using them for the first time, you have to assign the numerical values to the buttons, which should be transmitted when you tap them. 
 For the cursor buttons I have given the numerical values 1 to 4 in clockwise direction. I assigned the numerical value 5 to the other buttons. These values are passed in the sketch to the variable  blueToothVal &amp;nbsp;and lead in the &amp;nbsp;if-pointers of  the function  loop()  to determine the code for the drive level.    
 The changes from infrared to Bluetooth and motor controller V2 to V1 cause some modifications in the main part of the sketch. On the other hand, almost nothing changes in the motor() function. Only in the notation, due to the different program libraries (libraries), the functions motor1-&amp;gt;setSpeed() now becomes motor1.setSpeed(). 
 The program code: Build RC Car for Arduino 
 * Sample Code  for  Robot Car with Motor Shield V1 and BT receiver   HC-05 , as of  20220515 
* based on Adafruit Motor shield V2 library, copyright Adafruit Industries LLC
*  this  code is  public  domain, enjoy!
* modified  for  Funduino
* Pins
* BT VCC to Arduino  5V out.
* BT GND to GND
* Arduino  A1=15  (SS RX) - BT TX no need voltage divider
* Arduino  A2=16  (SS TX) - BT RX through a voltage divider (5v to  3.3v )
*/

  #include   &amp;lt;AFMotor.h&amp;gt;  
AF_DCMotor motor1 (2 );
AF_DCMotor motor2 (3 );

  #include   &amp;lt;SoftwareSerial.h&amp;gt;  
 // initialize HC-05 
 SoftwareSerial  BTSerial (15 ,  16 );  // RX, TX cross to TX, RX(voltage divider) 
 char  blueToothVal;
 int  x =  0 ;
 int  y =  0 ;
 int  left =  0 ;
 int  right =  0 ;
 int  code =  5555 ;
 int  speedL =  0 ;
 float  factor =  1.8 ;  // Correction for speedLevel 255/100 * 6V/VBatt 

 void   setup () {
  Serial  .begin  (9600 );  // set up Serial Monitor at 9600 bps 
  Serial  .println ( &quot;Motor test!&quot; );
  BTSerial .begin  (9600 );  // set up transmission speed for HC-12 
  Serial  .println ( &quot;SoftwareSerial initialized! &quot;);
}  // end setup 

 void   loop () {
  if (BTSerial .available ())  //if data is received  ... 
 Serial.print(&quot;available&quot;);     
{
    blueToothVal=BTSerial .read () ;//..if they should be read out 
 Serial.println(blueToothVal); 
  }
    if  (blueToothVal== &#039;1&#039; )  //if the Bluetooth module receives a &quot;1&quot; .
    {
      if  ( code&amp;lt;9000 ) code = code +  1000 ;     
      Serial  .print ( &quot;code = &quot; );
      Serial  .println (code);
    }
    else   if  (blueToothVal== &#039;2&#039; )  //if the Bluetooth module receives a &quot;2&quot; .
    {
      if  (( code-1000*int ( code/1000 )) &amp;lt;900 ) code = code +  100 ;
      Serial  .print ( &quot;code = &quot; );
      Serial  .println (code);
    }
    else   if  (blueToothVal== &#039;3&#039; )  //if the Bluetooth module receives a &quot;3.&quot; 
    {
      if  ( code&amp;gt;2000 ) code = code -  1000 ;     
      Serial  .print ( &quot;code = &quot; );
      Serial  .println (code);
    }
    else   if  (blueToothVal== &#039;4&#039; )  //if the Bluetooth module receives a &quot;4&quot; .
    {
    if  ( code-1000*int ( code/1000 ) &amp;gt;  200 ) code = code -  100 ;
      Serial  .print ( &quot;code = &quot; );
      Serial  .println (code);
    } 
    else   if  (blueToothVal== &#039;5&#039; )  //if the Bluetooth module receives &quot;5&quot; ...
    { 
      code =  5555 ;
      Serial  .print ( &quot;code = &quot; );
      Serial  .println (code);    
    }
    delay  (200 );  //little delay for better serial communication and to avoid bouncing 
    motor();
}  // end loop 

 void  motor(){
  int  speedLevel [9 ] ={-100  ,-80  ,-60  ,-40  ,0  ,40  ,60  ,80  ,100} ;
  y =  int (code /  1000 );
  x =  int ((code -  1000*y ) /  100 );
  speedL = speedLevel[ y-1 ];
  Serial  .print ( &quot;code = &quot; );
  Serial  .print (code);
  Serial  .print ( &quot; y = &quot; );
  Serial  .print (y);
  Serial  .print ( &quot; x = &quot;);
  Serial  .print (x);
  Serial  . print( &quot; speedL = &quot;);
  Serial  .println (speedL);

  //Correction of speed steps for curve travel 
  if  ( x==1 ){
    right =  speedL+20 ;
    left =   speedL-20 ;
  }
  else   if  ( x==2 ){
    right =  speedL+15 ;
    left =   speedL-15 ;
  }
  else   if  ( x==3 ) {
    right =  speedL+10 ;
    left =   speedL-10 ;
  }
  else   if  ( x==4 ) {
    right =  speedL+5 ;
    left =   speedL-5 ;
  }
  else   if  ( x==6 ) {
    right = speedL  -5 ;
    left =  speedL+5 ;
  }
  else   if  ( x==7 ) {
    right =   speedL-10 ;
    left =  speedL+10 ;
  }
  else   if  ( x==8 ) {
    right =   speedL-15 ;
    left =  speedL+15 ;
  }
  else   if  ( x==9 ) {
    right =   speedL-20 ;
    left =  speedL+20 ;
  }
  else  {
    right = speedL;
    left = speedL;
  }

  //Input the speed levels for &quot;left&quot; and &quot;right 
  Serial  .print ( &quot;left = &quot; );
  Serial  .print (left);
  Serial  .print ( &quot; right = &quot; );
  Serial  .println (right);

  if  (left &amp;lt;  40  &amp;amp; left &amp;gt;  -40 ) {
    motor1 .run (RELEASE);
  }
  if  (right &amp;lt;  40  &amp;amp; right &amp;gt;  -40 ) {
    motor2 .run (RELEASE);
  }
  if  ( left&amp;gt;=40 ) {
    if  ( left&amp;gt;100 )  left=100 ;
      motor1 .run (FORWARD);
      motor1 .setSpeed (left * factor);
  }
  if  ( right&amp;gt;=40 ) {
    if  ( right&amp;gt;100 )  right=100 ;
      motor2 .run (FORWARD);
      motor2 .setSpeed (right * factor);
  }
  if  (left&amp;lt;=  -40 ) {
    if  ( left&amp;lt;-100 )   left=-100 ;
      motor1 .run (BACKWARD);
      left = -left;
      motor1 .setSpeed (left * factor);
  }
  if  (right&amp;lt;=  -40 ) {
    if  ( right&amp;lt;-100 )   right=-100 ;
      motor2 .run (BACKWARD);
      right = -right;
      motor2 .setSpeed (right * factor);
  }
}  // end motor  
 So much for the second cheapest solution for a Robot Car with remote control (assuming you have an Android smartphone). Next time I will show how easy it is to integrate a 433 MHz transceiver HC-12. With this, even several hundred meters of range can be achieved. However, the costs increase, because now two transceivers and another micro controller are needed. See you then. 
                ]]>
            </content>

                            <updated>2022-06-20T08:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Build RC Car for Arduino: Autonomous vehicle - part 2</title>
            <id>https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-2</id>
            <link href="https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-2"/>
            <summary type="html">
                <![CDATA[
                
                                            Welcome to the second installment of our new blog series on robot cars. In the first part, we learned about the basics for the basic vehicle. This time we want to address possibilities of remote control, developing a code system in the process...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                  Understanding the mobility of the future with robot cars, part 2  
 Welcome to the second installment of our new blog series on robotic cars. In the  first part , we learned about the basics for the basic vehicle. This time, we will discuss remote control options, develop a code system to determine the speed levels of the robot car, and finally implement a simple remote control with an infrared remote control. 
 Why do I need speed steps for an RC car for Arduino microcontrollers? 
 1. To control the motor speeds from another device, there is basically the possibility to use a potentiometer (poti) to continuously determine and transmit values, or to increase or decrease the value of the speed step by pressing a button. On the following pictures some selected examples, on the first picture joystick controls: 
 &amp;nbsp;  
 &amp;nbsp; 
 In the second picture we see infrared remote controls, a smartphone app with Bluetooth receiver, and the LCD1602 keypad shield that can be operated with a 433 MHz transceiver, among others: 
 &amp;nbsp;  
 &amp;nbsp; 
 To achieve a uniform scheme, it makes sense to use the map() function to reduce the analog values of the pot to values that can be transmitted via radio. The analog to digital converter provides 10 bit numbers, i.e. values between 0 and 1023. The center position of the mini joysticks is about 511. If you divide the value by 100, you can get two values (x and y direction) with one joystick, which are between 0 and 10 or if you use the map() function between 1 and 9. This is sufficient for entering the speed and for driving curves. No matter if we determine 11 or 9 values, standstill means value 5 in y-direction and for driving straight also value 5. 
 Looking at the controller with the two joysticks (part of the  4DOF Mini robot arm kit with joysticks and servo drive ), I decide to use a code between 1111 and 9999, which is easy to transfer, considering the variety of different systems. The first digit can be used for the y-direction of the left joystick, the second digit for the x-direction of the left joystick, the third and fourth digit for an optional second joystick or certain keys. In the first example with the IR remote control, we only need the first two digits of the four-digit code. 
 The speed control of the RC Car for Arduino 
 The speed control of the motors is done with pulse width modulation (PWM). The value for the so-called duty cycle is an 8-bit number, i.e. a value between 0 and 255 (=2 to the power of 8 -1). If you apply voltages between 0 and 6V to the motor with an adjustable power supply, you will notice that up to approx. 1.5 V nothing is noticeable. Then the motor starts to hum, but does not move. If you measure the current at the same time, you will notice a relatively high value. The energy is converted into heat and humming - not really good. From 2.4 - 3 volts the motor starts to rotate, the amperage drops a bit when the motor is unloaded. After that, the speed increases depending on the applied voltage. When regulating the voltage down, the motor will turn down to below 2 volts, but if it comes to a stop, for example due to increased frictional resistance or an obstacle, it will not restart. Conclusion: values below approx. 2.4 volts should be avoided, the input should be set equal to 0 (zero) to prevent unnecessary wear and power consumption. Except standstill (code=5) we need Duty Cycle between approx. 40% and 100% with a supply voltage of 6V for the motors. 
 The power supply for the RC Car for Arduino 
 We have already discussed several possibilities of power supply in the first part. Four AA batteries of 1.5V each result in 6V, the maximum voltage of the small yellow motors. Four AA batteries of 1.2V each are not sufficient as power supply. You then need a battery holder for 6 batteries and that gives 7.2 volts. And two lithium-ion batteries (nominal voltage 3.7V) deliver more than 8 volts when fully charged. So it makes sense to set a factor in the program that limits the voltage of the highest drive level at 6V. 
 The control of the RC Car for Arduino 
 If the driving instructions are given with buttons, which may even be in a smartphone app, the appropriate value is increased or decreased to the output value 55xx (standstill) without exceeding the maximum. 
 Reading out the code correctly 
 The assignment of the first digit of the code to the required values of the speed steps is done via the index of a list with the respective numerical values. 
 Conclusion: With a four-digit code we can control speed and cornering with the first two digits, the rear two digits are used for other functions (not needed at first). So, for example, code95xx for fastest straight ahead travel, 55xx for standstill, 77xx for forward travel to the right.&amp;nbsp; 
 
 
 
 
 
 y ↓ 0&amp;nbsp; x→ 
 
 
 1 
 
 
 2 
 
 
 3 
 
 
 4 
 
 
 5 
 
 
 6 
 
 
 7 
 
 
 8 
 
 
 9 
 
 
 
 
 9 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  ↑  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 8 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  ↑  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 7 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  ↑  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 6 
 
 
 ← 
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
 ↑ 
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
 → 
 
 
 
 
 5 
 
 
 ← 
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
  0  
 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 &amp;nbsp; 
 
 
 → 
 
 
 
 
 4 
 
 
 ← 
 
 
 &amp;nbsp; 
 
 
 ↙ 
 
 
 &amp;nbsp; 
 
 
 ↓ 
 
 
 &amp;nbsp; 
 
 
 ↘ 
 
 
 &amp;nbsp; 
 
 
 → 
 
 
 
 
 3 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 
  ↙  
 
 
 &amp;nbsp; 
 
 
  ↓  
 
 
 &amp;nbsp; 
 
 
  ↘  
 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 2 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 
  ↙  
 
 
 &amp;nbsp; 
 
 
  ↓  
 
 
 &amp;nbsp; 
 
 
  ↘  
 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 1 
 
 
  ←  
 
 
 &amp;nbsp; 
 
 
  ↙  
 
 
 &amp;nbsp; 
 
 
  ↓  
 
 
 &amp;nbsp; 
 
 
  ↘  
 
 
 &amp;nbsp; 
 
 
  →  
 
 
 
 
 
 &amp;nbsp; 
 Now we want to build our first Smart Robot Car with the kit, an ATmega328 microcontroller (design of the UNO R3), a MotorShield V2 and IR transmitter and receiver. 
 The Motor Shield V2 can control up to four motors. For the connection of the control lines the so-called I2C bus with the connections SDA (=Serial Data) at the analog input A4 and SCL (=Serial Clock) at A5 are used. Adafruit has also developed and provided a suitable program library for this. Attention: The libraries for Motor Shields V1 and V2 are not compatible. 
 &amp;nbsp;  
 Picture Motor Shield V2 with modification:  Soldered socket connectors (female connectors) for connection of additional equipment 
 No matter which Motor Shield you want to use - V1 or V2 -,&amp;nbsp; it makes sense to solder in additional female connectors for both Motor Shields to connect Bluetooth or 433 MHz transmitters/receivers or sensors later. More about this in the following blog posts. The IR receiver only needs power supply from pin 3 and 4 and pin2 for the IR receiver. The soldering iron can still stay cold. 
 For control we will first use the small infrared remote control from Funduino and an IR receiver. Although the &quot;naked&quot; IR sensor will do, I recommend the small breakout board, as it has an LED that flickers when IR signals are received; a valuable tool when looking for a fault. 
 The sketch is composed of two tried and tested parts: Armin Joachimsmeyer&#039;s example sketch, which he added to his great IRremote program library, and a Robot Car sketch by the author based on Adafruit&#039;s program library. 
 The program code for the RC Car for Arduino 
  /* Sample Code for Robot Car with Motor Shield V2 and IR receiver, as of 20220515
* based on Adafruit Motor shield V2 library, copyright Adafruit Industries LLC, 2009
* and SimpleReceiver.cpp, part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote
* MIT License Copyright (c) 2020-2022 Armin Joachimsmeyer
* modified for Funduino
* Motor Shield V2 utilizes I2C with SDA=A4 and SCL=A5
* IRreceiver utilizes Pin 2
 ************************************************************************************
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the &quot;Software&quot;), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *************************************************************************************/ 
 
  #include   &amp;lt;Adafruit_MotorShield.h&amp;gt;  
 // Create the motor shield object with the default I2C address 0x60 
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
 // Select which &#039;port&#039; M1, M2, M3 or M4.  
Adafruit_DCMotor *motor1 = AFMS.getMotor (2 );
Adafruit_DCMotor *motor2 = AFMS.getMotor (3 );

 // define protocol for remote control, for more see samples code SimpleReceiver.cpp 
  #define  DECODE_NEC  // Includes Apple and Onkyo, also for tiny Funduino remote control  
 //#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols 
  #define  IR_RECEIVE_PIN 2  // instead of #include &quot;PinDefinitionsAndMore.h&quot;  
  #include   &amp;lt;Arduino.h&amp;gt;  
  #include   &amp;lt;IRremote.hpp&amp;gt;  

 // IR Receiver signal connected to Pin2, VCC to Pin3, GND to Pin4 
 int  IR_GND =  4 ;  
 int  IR_VCC =  3 ;

 int  x =  0 ;
 int  y =  0 ;
 int  left =  0 ;
 int  right =  0 ;
 int  code =  5555 ;
 int  speedL =  0 ;
 float  factor =  1.8 ;  // Correction for speedLevel 255/100 * 6V/VBatt 

 void   setup () {
  Serial  .begin  (9600 );
  Serial  .println ( &quot;Motor test!&quot; );
  Serial  .print ln( &quot;Motorshield v2 - DC Motor test!&quot; );
  if  (!AFMS .begin ()) {  // create with the default frequency 1.6KHz 
    Serial  .println ( &quot;Could not find Motor Shield. Check wiring.&quot; );
    while  (1 );
  }
  Serial  .println ( &quot;Motor Shield found.&quot; );
  // Just to know which program is running on my Arduino 
  Serial  .println (F( &quot;START &quot;  __FILE__  &quot; from &quot;  __DATE__  &quot;\r\nUsing library version &quot;  VERSION_IRREMOTE));
  // Start the receiver 
  IrReceiver .begin (IR_RECEIVE_PIN);  //, ENABLE_LED_FEEDBACK); 
  Serial  .print (F( &quot;Ready to receive IR signals of protocols: &quot; ));
  printActiveIRProtocols( &amp;amp;Serial );
  Serial  . print(F( &quot;at pin &quot; ));
  Serial  .println (IR_RECEIVE_PIN);  
  // initialize digital pins as output for power supply 
  pinMode (IR_GND ,OUTPUT );
  pinMode (IR_VCC ,OUTPUT );
  digitalWrite (IR_GND ,LOW );
  digitalWrite (IR_VCC ,HIGH );    
}  // end setup 

 void   loop () {
  if  (IrReceiver.decode()) {
      // Print a short summary of received data 
      IrReceiver.printIRResultShort( &amp;amp;Serial );
      if  (IrReceiver.decodedIRData.protocol == UNKNOWN) {
          // We have an unknown protocol here, print more info 
          IrReceiver.printIRResultRawFormatted( &amp;amp;Serial , true);
      }
      Serial  .println ();
      /*
       * !!!Important!!! Enable receiving of the next value,
       * since receiving has stopped after the end of the current received data packet.
       */ 
      delay  (100 );  // Debounce, no fast retry      
      IrReceiver.resume();  // Enable receiving of the next value 
      /*
       * Finally, check the received data and perform actions according to the received command
       */ 
  if  (IrReceiver.decodedIRData.command ==  0x46 ) {
    if  ( code&amp;lt;9000 ) code = code +  1000 ;     
    Serial  .print ( &quot;code = &quot; );
    Serial  .println (code);
    }
  else   if  (IrReceiver.decodedIRData.command ==  0x15 ) {
    if  ( code&amp;gt;2000 ) code = code -  1000 ;     
    Serial  .print ( &quot;code = &quot; );
    Serial  .println (code);
    } 
  else   if  (IrReceiver.decodedIRData.command ==  0x43 ) {
    if  (( code-1000*int ( code/1000 )) &amp;lt;900 ) code = code +  100 ;    
    Serial  .print ( &quot;code = &quot; );
    Serial  .println (code);
    }
  else   if  (IrReceiver.decodedIRData.command ==  0x44 ) {
    if  ( code-1000*int ( code/1000 ) &amp;gt;  200 ) code = code -  100 ;
    Serial  .print ( &quot;code = &quot; );
    Serial  .println (code);
    }
  else   if  (IrReceiver.decodedIRData.command ==  0x40 ) {
    code =  5555 ;
    Serial  .print ( &quot;Code = &quot; );
    Serial  .println (code);
    }
  else  {
    Serial  .print ( &quot;invalid code&quot; );
    }
  motor();
  }
}  // end loop 

 void  motor(){
  int  speedLevel [9 ] ={-100  ,-80  ,-60  ,-40  ,0  ,40  ,60  ,80  ,100} ;
  y =  int (code /  1000 );
  x =  int ((code -  1000*y ) /  100 );
  speedL = speedLevel[ y-1 ];
  Serial  .print ( &quot;code = &quot; );
  Serial  .print (code);
  Serial  .print ( &quot; y = &quot; );
  Serial  .print (y);
  Serial  .print ( &quot; x = &quot;);
  Serial  .print (x);
  Serial  . print( &quot; speedL = &quot;);
  Serial  .println (speedL);

  //Correction of speed steps for curve travel 
  if  ( x==1 ){
    right =  speedL+16 ;
    left =   speedL-16 ;
  }
  else   if  ( x==2 ){
    right =  speedL+13 ;
    left =   speedL-13 ;
  }
  else   if  ( x==3 ) {
    right =  speedL+10 ;
    left =   speedL-10 ;
  }
  else   if  ( x==4 ) {
    right =  speedL+7 ;
    left =   speedL-7 ;
  }
  else   if  ( x==6 ) {
    right = speedL  -7 ;
    left =  speedL+7 ;
  }
  else   if  ( x==7 ) {
    right =   speedL-10 ;
    left =  speedL+10 ;
  }
  else   if  ( x==8 ) {
    right =   speedL-13 ;
    left =  speedL+13 ;
  }
  else   if  ( x==9 ) {
    right =   speedL-16 ;
    left =  speedL+16 ;
  }
  else  {
    right = speedL;
    left = speedL;
  }

  //Input the speed levels for &quot;left&quot; and &quot;right 
  Serial  .print ( &quot;left = &quot; );
  Serial  .print (left);
  Serial  .print ( &quot; right = &quot; );
  Serial  .println (right);

  if  (left &amp;lt;  40  &amp;amp; left &amp;gt;  -40 ) {
    motor1-&amp;gt;run (RELEASE);
  }
  if  (right &amp;lt;  40  &amp;amp; right &amp;gt;  -40 ) {
    motor2-&amp;gt;run (RELEASE);
  }
  if  ( left&amp;gt;=40 ) {
    if  ( left&amp;gt;100 )  left=100 ;
      motor1-&amp;gt;run (FORWARD);
      motor1-&amp;gt;setSpeed (left * factor);
  }
  if  ( right&amp;gt;=40 ) {
    if  ( right&amp;gt;100 )  right=100 ;
      motor2-&amp;gt;run (FORWARD);
      motor2-&amp;gt;setSpeed (right * factor);
  }
  if  (left&amp;lt;=  -40 ) {
    if  ( left&amp;lt;-100 )   left=-100 ;
      motor1-&amp;gt;run (BACKWARD);
      motor1-&amp;gt;setSpeed (-left * factor);
  }
  if  (right&amp;lt;=  -40 ) {
    if  ( right&amp;lt;-100 )   right=-100 ;
      motor2-&amp;gt;run (BACKWARD);
      motor2-&amp;gt;setSpeed (-right * factor);
  }
}  // end motor 
 
 Explanation of the program code for the RC Car 
 After including the libraries for the Motor Shield V2 and IRremote, two motors are instantiated with the number at the terminal block of the controller and some global variables are declared (data type) and initialized (initial value). 
 In the function  setup()  the serial interface and the IR receiver are initialized and the pins for the power supply of the IR receiver are set up as outputs with the state HIGH or LOW. 
 In the function  loop()  first the signal of the IR remote control is received, then depending on the pressed key the code for the motor control is changed. The cursor keys up and down change the first digit, left and right the second digit of the code in the value range 1 to 9. The key X leads to standstill with code 5555. The third and fourth digit of the code are currently not yet significant. At the end, the self-defined function  motor()  is called without arguments, because we had defined the variables globally, i.e. valid in all functions. 
 In the self-defined function  motor() , which we will also use in other configurations with other remote controls, the speed steps for the left and right motor are determined from the code. The percentage value of the speed level is finally converted into the PWM value for  setSpeed  with the factor defined at the beginning. 
 &amp;nbsp;  
 Now the Robot Car is ready for use. Works fine as long as you can maintain the optical connection between remote control and IR receiver. However, when driving on the road, I have experienced that strong sunlight hinders reception. That&#039;s why I&#039;m switching to radio remote control. See you soon. 
                ]]>
            </content>

                            <updated>2022-06-09T07:30:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Build RC Car for Arduino: Autonomous vehicle - part 1</title>
            <id>https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-1</id>
            <link href="https://funduinoshop.com/en/blog/projects/build-rc-car-for-arduino-autonomous-vehicle-part-1"/>
            <summary type="html">
                <![CDATA[
                
                                            Welcome to a new blog series about robot cars. In the first part we will get to know the basics of it, so to speak as a decision support for the purchase decision, which chassis, which microcontroller and which type of remote control...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                  Understanding the mobility of the future with robot cars  
 Welcome to a new blog series about robot cars. In the first part, we will learn the basics of it, so to speak, to help you decide which chassis, microcontroller and type of remote control is best for you. 
 Two or four wheels - weighing the pros and cons for building RC cars for Arduino 
 Let&#039;s start with the chassis and look at the advantages and disadvantages of the inexpensive kits with two or four powered wheels. All of them have electric motors in common, so these alone are not a selection criterion. The two-wheeled robot cars are initially less expensive because they do not have the cost of two more electric motors and wheels. Instead, they have one or two support wheels, which give the RC cars great maneuverability. So if you want to &quot;step up to the plate&quot;, this is the way to go. However, in this price range of DC motors, you can&#039;t expect them to run smoothly with high precision. Therefore, the straight running is not as good as with the four-wheeled variant. Especially when starting up the motors show a higher tracking accuracy, but cornering is only possible with significantly larger radii. Another advantage of the four-wheeled chassis is more space for batteries, microcontroller, possibly DC/DC converter and sensors. 
   
 The choice of microcontroller for building an RC car 
 The next question is about the microcontroller and the way it is programmed. For example, the greatest computing power on the small chassis has a micro computer of the type Raspberry Pi. Especially in terms of remote control, the types with built-in WiFi and Bluetooth offer advantages and you can even transmit images from a Raspberry Pi camera. Programming is done in the widely used Python programming language, but the system startup of the Linux-based Raspberry Pi OS takes about a minute. Another drawback of the Raspis (short for Raspberry Pi) is the need for a good 5V power supply. This requires a good DC/DC converter. 
 In connection with the topic of Bluetooth remote control, an example with Raspberry Pi and the Android APP BlueDot by Martin O&#039;Hanlon (staff member of the Raspberry Pi Foundation) will be shown in a later episode. 
 Much faster is the system startup with a Micro Controller based on the ATmega 328, e.g. the  Funduino Uno  or  Funduino&amp;nbsp;Nano . About one second after power on you can start with the control inputs, no booting from microSD card, the program once uploaded is not forgotten. The input voltage can be between 5 and 9 volts. Programming is done in the  Arduino IDE , a development environment similar to C/C++ (For further explanation see  https://funduino.de/hardware-software) . Therefore, we will first look at examples with the Funduino Uno R3, for which perfect motor controllers are available as so-called shields. These are simply plugged onto the Uno and so-called libraries help us with the programming. 
 Excursus: What is a motor controller/motor driver? 
 Due to the very limited current at the outputs of the micro controllers, larger consumers - and this includes all kinds of electric motors and relays - require an external power supply and an electronic circuit that converts the control signal of the micro controller. However, the requirements for this integrated circuit are even higher: On the one hand, it should allow a variable speed of the motor, on the other hand, we also want to be able to change the direction of rotation of the motor by reversing the polarity. 
 Using the IC L293D as an example, we will now explain how it works. Basically this DIP component with sixteen &quot;legs&quot;/connections is sufficient as a motor controller for two electric motors.     
 The voltage supply of the IC is at the connections VCC1 and Ground. We can tap this voltage at the micro controller. The voltage supply of the motors is done via VCC2 and Ground. Here we connect the battery(ies) (e.g. 6 or 9 volts). For bigger motors the IC has to be cooled, for the small yellow ones from the kit not. 
 The one motor we connect to 1Y and 2Y, the corresponding control lines to the MCU (Micro Controller Unit) are 1A, 2A and 1,2EN. 
 Reversing the polarity of the motors to change the driving direction is basically done with a so called H-circuit. We implement this with our micro controller by placing two output pins (these go to 1A and 1B) at either HIGH or LOW. 
 The speed change is done as in  example no. 04 - pulsating LED  with pulse width modulation (PWM), i.e. the very fast switching on and off of the voltage. Therefore we need for the connection 1,2EN (&quot;Enable&quot;) a PWM capable output at the MCU (these are the pins with the tilde ~). 
 For the second motor, the connections 3A, 4A and 3,4EN are connected to pins of the MCU. 
 The right picture (Logic Diagram) explains how the IC works. We can see the four amplifiers that give the input signals 1A to 4A respectively with the battery voltage to the outputs 1Y to 4Y. However, this is only done if the PWM inputs 1,2EN and 3,4EN are also switched HIGH. 
 Two of these ICs L293D are installed on the Motor Shield V1, so that up to four motors can be connected here. 
 To avoid using too many pins, there is a so-called shift register (SN74HC595) in the middle of the Motor Shield V1. To explain how it works would go beyond the scope of this article. Fortunately, the colleagues of the New York company Adafruit did most of the programming work for us and provided a library to control the motors easily.    
 Picture Motor Shield V1 with modification:   Soldered socket connectors (female connectors) for connecting additional equipment 
 &amp;nbsp; 
 The Motor Shield V2 can also control up to four motors and uses a similar IC, but for the connection of the control lines the so-called I2C bus with the connections SDA (=Serial Data) at the analog input A4 and SCL (=Serial Clock) at A5. Adafruit has also developed and provided a suitable program library for this purpose. 
   
 Picture Motor Shield V2 with modification:  Soldered socket connectors (female connectors) for connection of additional equipment 
 On both Motor Shields additional female connectors are soldered in order to connect Bluetooth or 433 MHz transmitters/receivers or sensors later. More about this in one of the following blog posts. 
 Power supply and control for an RC Car for Arduino microcontroller 
 If we want our robot car to drive independently, we have to disconnect it from the USB port of the PC. This means that the power supply will be lost as well. From now on, the command center (MCU) and electric motors will be powered by batteries or rechargeable batteries. Here, the motors are by far the larger consumers. The battery holder that comes with most kits is for four Mignon (AA) batteries, i.e. 6 volts for MCU and motors. If you want to use rechargeable batteries, you should use either six Mignon (AA) batteries or two 18650 lithium-ion batteries because of the lower voltage. 
 For control, in the next episodes we will first learn about remote controllers with infrared remote control, Bluetooth transceivers with smartphone APP or a second micro controller also with BT transceiver HC-05, and radio remote controllers with 433Mhz and 2.4 GHz. The blog series will conclude with aspects of autonomous driving, primarily obstacle detection. See you soon. 
 &amp;nbsp; 
                ]]>
            </content>

                            <updated>2022-06-03T11:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">WISENT Class Air Cushion Landing Craft</title>
            <id>https://funduinoshop.com/en/blog/projects/wisent-class-air-cushion-landing-craft</id>
            <link href="https://funduinoshop.com/en/blog/projects/wisent-class-air-cushion-landing-craft"/>
            <summary type="html">
                <![CDATA[
                
                                            On many model ship showcases, most of the ships are built down to the last detail and in very high quality. It&#039;s a pity that this is often overlooked by spectators. Spectacular and not everyday models...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Model making: WISENT class landing craft air cushion &quot;LCAC - Landing Craft Air Cushion&quot; 
 On many model ship shows most of the ships are built to the last&amp;nbsp;detail and in very high quality. It is a pity that this is often overlooked by&amp;nbsp;the spectators. Spectacular and not everyday&amp;nbsp;models are more likely to attract attention. Among them are without&amp;nbsp;doubt the hovercraft.&amp;nbsp;Why not build the largest of its kind as a model?&amp;nbsp;With a displacement of 550 tons, the Zubr class (Wisent class) is a giant.&amp;nbsp;A plastic model is available in 1:110. That was too small for me. 1:75 I just found&amp;nbsp;right. So build it yourself! 
 Build your own hovercraft: But how? 
 To read up on this subject, the book &quot;RC hovercrafts&quot; by&amp;nbsp;K.Jackson &amp;amp; M.Porter from the VTH publishing house was a valuable help. Which technical&amp;nbsp;components should make the model float had to be tried out&amp;nbsp;. Calculations were not very helpful here. At the end of the text a&amp;nbsp;list of the used battery and drive technology. A construction plan for&amp;nbsp;this type does not exist, so photos had to be used and a lot of&amp;nbsp;calculations were made. 
 The shell was built with a PU foam board and a power glue&amp;nbsp;from the hardware store. This went quite quickly. A 70 mm impeller, often used for styrofoam model airplanes, should make the Wisent&amp;nbsp;&quot;hover&quot;. The air skirt is made with rip nylon.&amp;nbsp;A material used in tent canvas and by skydivers&amp;nbsp;. 
 The power supply for the hovercraft landing craft 
 With the planned size of 900 x 400 mm, it was clear from the outset that it would not be an energy-saving model. An 18 V battery with 2.5 Ah from the&amp;nbsp;tool range - combined with a voltage converter - is to provide the desired voltage of an even 12 V.&amp;nbsp;A second voltage converter regulates the 12 V down to 9 V again&amp;nbsp;and thus supplies the propeller and the nautical lighting with an&amp;nbsp;even voltage.&amp;nbsp;Thus, the entire power supply comes from one battery.&amp;nbsp;Two of the outer propellers are designed for propulsion, the middle&amp;nbsp;motor was reversed and this propeller was put &quot;upside down&quot; on the  drive shaft. Reverse drives are thus possible without any problems.&amp;nbsp;The three drive nacelles were printed for me by the company - Ray Haller from Eibenstock - on&amp;nbsp;the 3D printer. They are controlled synchronously by a servo.&amp;nbsp;This drive concept has proven itself.&amp;nbsp;The 3.5 inch (approx. 9 cm) propellers come from the spare parts range for quadcopters.&amp;nbsp;Despite consistent lightweight construction, the model weighs in at 4.7 kg with all fittings&amp;nbsp;. This makes landing possible, but it is not suitable for trips&amp;nbsp;on land. Even the original is 99% of the time on the&amp;nbsp;water. 18 of this &quot;giant bison&quot; were built.&amp;nbsp;Ukraine, Korea, Russia, China and Greece used them. 
 Used components from Funduino: 
 1x&amp;nbsp; R4-E-0-1 :  EDF Turbine Impeller 70mm ADF70-28XL PLUS KV3900  1x R6-C-7-4:  Hobbywing SkyWalker 60A UBEC Brushless ESC&amp;nbsp;(40A controller gets too hot)  3x R5-E-4-3:  Ready ToSky 1306 KV3100 for 150 quadcopter  3x R6-E-1-4:  Hobbywing SkyWalker 12AE Brushless ESC  2x R12-B-8-2:  DC-DC Step Down Module 300W 20A 6-40V to 1.2-36V  
 1x Battery 2.5 Ah 18 V from Einhell (driving time approx. 15 min) The model is controlled with a Carson 6-channel remote control 2.4 GHz. 
                ]]>
            </content>

                            <updated>2022-05-04T15:30:00+02:00</updated>
                    </entry>

    
</feed>
