Luc Francoeur
Published © CC BY-NC-SA

Wifi RC Hummer

Controlling an RC truck with Arduino and Raspberry Pi.

AdvancedWork in progress2,823
Wifi RC Hummer

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Arduino UNO
Arduino UNO
×1
New Bright hummer h3
×1

Software apps and online services

Microsoft visual basic 6
Raspberry Pi raspbian easy install NOOBS package
Arduino IDE
Arduino IDE
Raspberry Pi motion webcam streamer instruction
Raspberry Pi mjpeg streamer instalation tutorial on raspbian

Story

Read more

Code

visual basic 6 pc code

VBScript
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{DF2BBE39-40A8-433B-A279-073F48DA94B6}#1.0#0"; "axvlc.dll"
Begin VB.Form Form_v2 
   BackColor       =   &H00808080&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "push wifi hummer"
   ClientHeight    =   6390
   ClientLeft      =   840
   ClientTop       =   630
   ClientWidth     =   11790
   FillColor       =   &H00FFFFFF&
   Icon            =   "Form2.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   16000
   ScaleMode       =   0  'User
   ScaleWidth      =   11790
   ShowInTaskbar   =   0   'False
   WhatsThisHelp   =   -1  'True
   Begin VB.Frame Frame3 
      BackColor       =   &H80000010&
      Caption         =   "Video Stream Adress"
      Height          =   615
      Left            =   120
      TabIndex        =   24
      Top             =   3120
      Width           =   3015
      Begin VB.TextBox Text3 
         Height          =   285
         Left            =   120
         TabIndex        =   25
         Text            =   "Text3"
         Top             =   240
         Width           =   2775
      End
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H80000010&
      Caption         =   "Port"
      Height          =   615
      Left            =   1680
      TabIndex        =   22
      Top             =   2400
      Width           =   1455
      Begin VB.TextBox Text2 
         Height          =   285
         Left            =   120
         TabIndex        =   23
         Text            =   "Text2"
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H80000010&
      Caption         =   "Ip Address"
      Height          =   615
      Left            =   120
      TabIndex        =   20
      Top             =   2400
      Width           =   1455
      Begin VB.TextBox Text1 
         Height          =   285
         Left            =   120
         TabIndex        =   21
         Text            =   "Text1"
         Top             =   240
         Width           =   1215
      End
   End
   Begin AXVLCCtl.VLCPlugin VLCPlugin1 
      Height          =   6375
      Left            =   3360
      TabIndex        =   19
      Top             =   0
      Width           =   8415
      AutoLoop        =   0   'False
      AutoPlay        =   -1  'True
      Toolbar         =   0   'False
      ExtentWidth     =   14843
      ExtentHeight    =   11245
      MRL             =   "http://192.168.2.174:8081"
      Object.Visible         =   -1  'True
      Volume          =   0
      StartTime       =   0
      BaseURL         =   ""
      BackColor       =   0
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Command6"
      Height          =   495
      Left            =   2880
      TabIndex        =   17
      Top             =   5520
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Command5"
      Height          =   495
      Left            =   2280
      TabIndex        =   16
      Top             =   5520
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Command4"
      Height          =   495
      Left            =   1680
      TabIndex        =   15
      Top             =   5520
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Command3"
      Height          =   495
      Left            =   1080
      TabIndex        =   14
      Top             =   5520
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Command2"
      Height          =   495
      Left            =   480
      TabIndex        =   13
      Top             =   5520
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.Timer Tmrsend 
      Enabled         =   0   'False
      Interval        =   150
      Left            =   2040
      Top             =   3000
   End
   Begin VB.Timer tmrcheck 
      Interval        =   200
      Left            =   1560
      Top             =   3000
   End
   Begin VB.Timer tmrin 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   1560
      Top             =   2520
   End
   Begin VB.Timer tmrout 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   2040
      Top             =   4440
   End
   Begin VB.Timer tmrflashleft 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   1560
      Top             =   4440
   End
   Begin VB.Timer tmrfog 
      Enabled         =   0   'False
      Interval        =   2
      Left            =   2040
      Top             =   2520
   End
   Begin VB.Timer tmrbeam 
      Enabled         =   0   'False
      Interval        =   2
      Left            =   2040
      Top             =   3480
   End
   Begin VB.Timer call_timer 
      Left            =   1560
      Top             =   3480
   End
   Begin VB.CommandButton Command1 
      Caption         =   "CON"
      Height          =   375
      Left            =   2400
      TabIndex        =   5
      Top             =   1800
      Width           =   735
   End
   Begin MSWinsockLib.Winsock sock 
      Left            =   1560
      Top             =   3960
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.CommandButton cmd_right 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      DownPicture     =   "Form2.frx":164A
      Enabled         =   0   'False
      Height          =   615
      Left            =   1440
      MaskColor       =   &H00808080&
      Picture         =   "Form2.frx":1D94
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   600
      UseMaskColor    =   -1  'True
      Width           =   735
   End
   Begin VB.CommandButton cmd_left 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      DownPicture     =   "Form2.frx":24DE
      Enabled         =   0   'False
      Height          =   615
      Left            =   0
      MaskColor       =   &H00808080&
      Picture         =   "Form2.frx":2C28
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   600
      UseMaskColor    =   -1  'True
      Width           =   735
   End
   Begin VB.CommandButton cmd_up 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      DownPicture     =   "Form2.frx":3372
      Enabled         =   0   'False
      Height          =   615
      Left            =   720
      MaskColor       =   &H00808080&
      Picture         =   "Form2.frx":3AD4
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   0
      UseMaskColor    =   -1  'True
      Width           =   735
   End
   Begin VB.CommandButton cmd_down 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      Enabled         =   0   'False
      Height          =   615
      Left            =   720
      MaskColor       =   &H00808080&
      Picture         =   "Form2.frx":4236
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   1200
      UseMaskColor    =   -1  'True
      Width           =   735
   End
   Begin VB.Timer tmrflashright 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   2040
      Top             =   3960
   End
   Begin VB.Label Label2 
      BackColor       =   &H80000010&
      Caption         =   "Camera Key's ( J : <- )  ( U :\ )                                         ( I : | ) ( O : / ) ( L : -> )"
      Height          =   495
      Left            =   240
      TabIndex        =   26
      Top             =   4080
      Width           =   2895
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "|"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   720
      TabIndex        =   18
      Top             =   600
      Width           =   735
   End
   Begin VB.Label Label8 
      Caption         =   "Label8"
      Height          =   375
      Left            =   2400
      TabIndex        =   12
      Top             =   1320
      Width           =   735
   End
   Begin VB.Label Label4 
      Caption         =   "Label4"
      Height          =   375
      Left            =   1560
      TabIndex        =   11
      Top             =   1800
      Width           =   735
   End
   Begin VB.Label Lblfog 
      BackColor       =   &H80000010&
      Caption         =   "F: fog"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   240
      Left            =   2280
      TabIndex        =   10
      Top             =   840
      Width           =   1095
   End
   Begin VB.Label Lblbeam 
      BackColor       =   &H80000010&
      Caption         =   "B: beam"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   240
      Left            =   2280
      TabIndex        =   9
      Top             =   600
      Width           =   1095
   End
   Begin VB.Label Label7 
      BackColor       =   &H80000010&
      Caption         =   "T: connect"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   240
      Left            =   2280
      TabIndex        =   8
      Top             =   360
      Width           =   1095
   End
   Begin VB.Label Label6 
      BackColor       =   &H80000010&
      Caption         =   "H: horn"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   240
      Left            =   2280
      TabIndex        =   7
      Top             =   120
      Width           =   1095
   End
   Begin VB.Label Label5 
      Caption         =   "Label5"
      Height          =   375
      Left            =   1560
      TabIndex        =   6
      Top             =   1320
      Width           =   735
   End
   Begin VB.Label Label3 
      BackColor       =   &H80000010&
      Caption         =   "Esc = Exit"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   360
      Left            =   0
      TabIndex        =   4
      Top             =   1920
      Width           =   1095
   End
End
Attribute VB_Name = "Form_v2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public direction As String
Public beam, fog, error As Integer
Dim datain As String
Public flashleft, flashright As Integer
Public ttime As Integer
Public address, port As String
Public upstatus, downstatus, leftstatus, rightstatus, hornstatus As Integer
Public output As Integer
Dim stream(6) As Integer



Private Sub call_timer_Timer()
    Call motion("manual", upstatus + downstatus + rightstatus + leftstatus + hornstatus)
    'Calls motion module.  Lets it know manual driving and what value to output to the
    'parallel port
End Sub

Private Sub Command1_Click()
  If sock.State = sckClosed Then ' if the socket is closed
    sock.RemoteHost = Text1.Text  ' set server adress
    sock.RemotePort = Text2.Text  ' set server port
    Label5.Caption = "Connected"
    VLCPlugin1.MRL = Text3.Text
    VLCPlugin1.Play
    Form_v2.Enabled = False
    Command1.Visible = False
    Command1.Enabled = False
    Form_v2.BorderStyle = "0"
    sock.Connect ' start connection attempt
  Else ' if the socket is open
    sock.Close ' close it
    Label5.Caption = "Not Connected"
    Form_v2.Enabled = True
    Command1.Enabled = True
    Command1.Visible = True
    VLCPlugin1.Stop
  End If
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    'Detects if control keys are pressed
    If KeyCode = vbKeyEscape Then End 'Exits
    If KeyCode = vbKeyT Then Call Command1_Click
    If KeyCode = vbKeyUp Or KeyCode = vbKeyW Then: cmd_up.BackColor = &HFF0000: cmd_up.Picture = cmd_up.DownPicture: upstatus = 1
    'If up arrow is pressed or W then change pictures (make it blue) and change upstatus.
    If KeyCode = vbKeyDown Or KeyCode = vbKeyS Then cmd_down.BackColor = &HFF0000: cmd_down.Picture = cmd_down.DownPicture: downstatus = 2
    'If down arrow is pressed or S then change pictures (make it blue) and change downstatus.
    If KeyCode = vbKeyLeft Or KeyCode = vbKeyA Then cmd_left.BackColor = &HFF0000: cmd_left.Picture = cmd_left.DownPicture: rightstatus = 4: tmrflashleft.Enabled = True
    'If left arrow is pressed or A then change pictures (make it blue) and change rightstatus.
    If KeyCode = vbKeyRight Or KeyCode = vbKeyD Then cmd_right.BackColor = &HFF0000: cmd_right.Picture = cmd_right.DownPicture: leftstatus = 8: tmrflashright.Enabled = True
    'If right arrow is pressed or D then change pictures (make it blue) and change leftstatus.
    If KeyCode = vbKeyH Then stream(3) = 1
    If KeyCode = vbKeyB Then tmrbeam.Enabled = True
    If KeyCode = vbKeyF Then tmrfog.Enabled = True
    If KeyCode = vbKeyJ Then stream(1) = 3: Label1.Caption = "<-"
    If KeyCode = vbKeyU Then stream(1) = 4: Label1.Caption = "\"
    If KeyCode = vbKeyI Then stream(1) = 5: Label1.Caption = "|"
    If KeyCode = vbKeyO Then stream(1) = 6: Label1.Caption = "/"
    If KeyCode = vbKeyL Then stream(1) = 7: Label1.Caption = "->"

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    'Stops output to that direction when key is lifted.
    'Changes pictures back to unactivated (none-blue).
    If KeyCode = vbKeyUp Or KeyCode = vbKeyW Then cmd_up.BackColor = &HFFFFFF: cmd_up.Picture = cmd_up.DisabledPicture: upstatus = 0
    If KeyCode = vbKeyDown Or KeyCode = vbKeyS Then cmd_down.BackColor = &HFFFFFF: cmd_down.Picture = cmd_down.DisabledPicture: downstatus = 0
    If KeyCode = vbKeyLeft Or KeyCode = vbKeyA Then cmd_left.BackColor = &HFFFFFF: cmd_left.Picture = cmd_left.DisabledPicture: rightstatus = 0: tmrflashright.Enabled = False: stream(2) = 0
    If KeyCode = vbKeyRight Or KeyCode = vbKeyD Then cmd_right.BackColor = &HFFFFFF: cmd_right.Picture = cmd_right.DisabledPicture: leftstatus = 0: tmrflashleft.Enabled = False: stream(2) = 0
    If KeyCode = vbKeyH Then stream(3) = 9
End Sub

Private Sub Form_Load()
    Text1.Text = "192.168.2.174"
    Text2.Text = "2001"
    Text3.Text = "http://192.168.2.174:8081"
   
    fog = 0
    beam = 0
    flashleft = 0
    flashright = 0
    Dim line As String
    Dim line2 As String
    'Stores {Arrow with white} pic in .DisabledPicture for each button
    cmd_up.DisabledPicture = cmd_up.Picture
    cmd_down.DisabledPicture = cmd_down.Picture
    cmd_left.DisabledPicture = cmd_left.Picture
    cmd_right.DisabledPicture = cmd_right.Picture
    'Following Opens Config.txt and collect Parallel Port Address and Refresh Rate
    'Open CurDir & "\config.txt" For Input As #1
    'Open CurDir & "\config.txt" For Input As #2
    'Line Input #1, line
'    Line Input #1, line
    'Line Input #2, line2
    line = "192.168.2.1"
    line2 = "2001"
    address = line 'sets the ip adress
    port = line2 'Sets ip port
    'lbladdress.Text = address 'displays address
    'txtport.Text = port
    call_timer.Interval = 5
    stream(0) = 9
    stream(1) = 9
    stream(2) = 9
    
End Sub


Private Sub sock_Close()
    sock.Close ' has to be
End Sub
  
Private Sub sock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    MsgBox "Socket Error " & Number & ": " & Description
    sock.Close ' close the erraneous connection
End Sub

'Motion Executor
Sub motion(direction As String, ttime As Integer)
    address = Form_v2.address
    Select Case direction
    Case 1 To 10
    Case "manual"
    'If manual driving, parallel port output required for direction has already
    'been calculated, so output value passed to ttime
    output = ttime
    Case "FF"
        output = 1
        stream(0) = 1
    Case "BB"
        output = 2
        stream(0) = 5
    Case "RR"
        output = 8
        stream(0) = 3
    Case "LL"
        output = 4
        stream(0) = 7
    Case "FR"
        output = 9
        stream(0) = 2
    Case "FL"
        output = 5
        stream(0) = 8
    Case "BR"
        output = 10
        stream(0) = 4
    Case "BL"
        output = 6
        stream(0) = 6
    Case "SS"
        output = 0
        stream(0) = 9
    End Select
    Rem vbOut address, output
    'sock.SendData output & Chr(0)
    If sock.State = sckConnected Then
     'If output = &HC Or output = &H1C Then output = output - 8
     'If output = &H3 Or output = &H13 Then output = output - 2
     'sock.SendData (stream(0) & stream(1) & stream(2) & stream(3) & stream(4))
      Label5.Caption = stream(0) & stream(1) & stream(2) & stream(3) & stream(4)
      
      Label7.BackColor = &HFF0000
      tmrin.Enabled = True
      tmrout.Enabled = True
      tmrcheck.Enabled = True
      
      
    Else
    tmrcheck.Enabled = False
      tmrout.Enabled = False
        Label5.Caption = "NOT sending data"
        Label7.BackColor = &H80000010
    End If
End Sub

Private Sub tmrbeam_Timer()
If beam = 1 Then
beam = 0
fog = 0
stream(1) = 9
Lblbeam.BackColor = &H80000010
Lblfog.BackColor = &H80000010
tmrbeam.Enabled = False
ElseIf beam = 0 Then
beam = 1
stream(1) = 1
Lblbeam.BackColor = &HFF0000
tmrbeam.Enabled = False
End If
End Sub


Private Sub tmrcheck_Timer()
Label8.Caption = error
If Label5.Caption = Label4.Caption Then
error = 0
End If
If Not Label5.Caption = Label4.Caption Then
error = 1
Tmrsend.Enabled = True

End If
End Sub

Private Sub tmrflashleft_Timer()
If flashleft = 0 Then
flashleft = 1
stream(2) = 1
tmrflashleft.Enabled = False
ElseIf flashleft = 1 Then
flashleft = 0
stream(2) = 9
tmrflashleft.Enabled = False
End If
End Sub

Private Sub tmrflashright_Timer()
If flashright = 0 Then
flashright = 1
stream(2) = 2
tmrflashright.Enabled = False
ElseIf flashright = 1 Then
flashright = 0
stream(2) = 9
tmrflashright.Enabled = False
End If
End Sub

Private Sub tmrfog_Timer()
If beam = 1 And fog = 0 Then
stream(1) = 2
fog = 1
Lblfog.BackColor = &HFF0000
tmrfog.Enabled = False
ElseIf beam = 1 And fog = 1 Then
stream(1) = 1
fog = 0
Lblfog.BackColor = &H80000010
tmrfog.Enabled = False
End If
End Sub

Private Sub tmrin_Timer()
Label4.Caption = datain
End Sub

Private Sub tmrout_Timer()
tmrcheck.Enabled = True
       
        sock.GetData datain, vbString
        
        If output = 1 Then
        stream(0) = 1
        tmrout.Enabled = False
        End If
       If output = 2 Then
        stream(0) = 5
        tmrout.Enabled = False
        End If
        If output = 8 Then
        stream(0) = 3
        tmrout.Enabled = False
        End If
        If output = 4 Then
        stream(0) = 7
        tmrout.Enabled = False
        End If
        If output = 9 Then
        stream(0) = 2
        tmrout.Enabled = False
        End If
        If output = 5 Then
        stream(0) = 8
        tmrout.Enabled = False
        End If
        If output = 10 Then
        stream(0) = 4
        tmrout.Enabled = False
        End If
        If output = 6 Then
        stream(0) = 6
        tmrout.Enabled = False
        End If
        If output = 0 Then
        stream(0) = 9
        tmrout.Enabled = False
        End If
End Sub

Private Sub Tmrsend_Timer()
If error = 1 And Label7.BackColor = &HFF0000 Then
sock.SendData (stream(0) & stream(1) & stream(2) & stream(3) & stream(4))
'sock.SendData (stream)
End If
End Sub

arduino receiver

Arduino
// Controlling a servo position using a Serial port
// by luc Francoeur <http://maaxinfo.cfun.fr/> 
// modified from Michal Rinott servo by potentiometer code <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>
Servo myservo;
uint16_t led[8];

const byte fog = 4;
const byte beam = 2;
const byte flashleft = 8;
const byte flashright = 7;
const byte brakes = 3;
const byte turnleft = 12;
const byte turnright = 13;
const byte avance = 10;
const byte center = 5;
const byte horn = 6;
char buffer[25];
byte cam = 88;
 

void setup() { 
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  
  myservo.attach(9);  // attaches the servo on pin 11 to the servo object
  
  Serial.begin(19200); // Speed of serial port
  Serial.flush();
 
  
}


void loop() { 
  pan();
  
  if (Serial.available() > 0) {
    byte index=0;
    delay(100); // let the buffer fill up
    byte numChar=Serial.available();
    if (numChar>20) {
      numChar=20;
      }
        while (numChar--) {
          buffer[index++] = Serial.read();
          }
    splitString(buffer);
  }
  }
 


void pan(){
  myservo.write(cam);
  delay(15);
}


void splitString(char* data) {

   char * parameter; 
   parameter = strtok (data, " ,");
   while (parameter != NULL) {
     setLED(parameter);
     parameter = strtok (NULL, " ,");
     }// Clear the text and serial buffers
       for (byte x=0; x<20; x++) {
         buffer[x]='\0';
         }
  Serial.flush();
}


void setLED(char *data) { 
  Serial.println(data);
  if (data[0]=='9') { //STALLED
    digitalWrite(center,HIGH);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,LOW);
    }
  if (data[0]=='1') { //FORWARD
    digitalWrite(center,HIGH);
    digitalWrite(avance,HIGH);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,LOW);
    }
  if (data[0]=='2') { //FORWARD-RIGHT
    digitalWrite(center,LOW);
    digitalWrite(avance,HIGH);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,HIGH);
    }
  if (data[0]=='3') { //RIGHT STALLED
    digitalWrite(center,LOW);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,HIGH);
    }
  if (data[0]=='4') { //REVERSE-RIGHT
    digitalWrite(center,LOW);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,HIGH);
  
    }
  if (data[0]=='5') { //REVERSE
    digitalWrite(center,HIGH);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,LOW);
    digitalWrite(turnright,LOW);
    
    }
  if (data[0]=='6') { //REVERSE-LEFT
    digitalWrite(center,LOW);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,HIGH);
    digitalWrite(turnright,LOW);
    
    }
  if (data[0]=='7') { // LEFT-STALLED
    digitalWrite(center,LOW);
    digitalWrite(avance,LOW);
    digitalWrite(turnleft,HIGH);
    digitalWrite(turnright,LOW);
    }
  if (data[0]=='8') { // FORWARD-LEFT
    digitalWrite(center,LOW);
    digitalWrite(avance,HIGH);
    digitalWrite(turnleft,HIGH);
    digitalWrite(turnright,LOW);
    }
  
  
    if ((data[1]=='9')&&(data[0]=='9')) { //BEAM off w/o FOG w/o BRAKES     
      digitalWrite(beam,LOW);
      analogWrite(brakes,0);
      digitalWrite(fog,LOW);
      }
    if ((data[1]=='9')&&((data[0]=='4')||(data[0]=='5')||(data[0]=='6'))) { //BEAM off w/o FOG w BRAKES
      digitalWrite(beam,LOW);
      analogWrite(brakes,255);
      digitalWrite(fog,LOW);
      }
    if ((data[1]=='1')&&((data[0]!='4')||(data[0]!='5')||(data[0]!='6'))) { //BEAM on w/o FOG w/o BRAKES
      digitalWrite(beam,HIGH);
      analogWrite(brakes,65);
      digitalWrite(fog,LOW);
      } 
    if ((data[1]=='1')&&((data[0]=='4')||(data[0]=='5')||(data[0]=='6'))) { //BEAM on w/o FOG w BRAKES
      digitalWrite(beam,HIGH);
      analogWrite(brakes,255);
      digitalWrite(fog,LOW); 
      }
    if ((data[1]=='2')&&((data[0]!='4')||(data[0]!='5')||(data[0]!='6'))) { //BEAM on w FOG w/o BRAKES
      digitalWrite(beam,HIGH);
      analogWrite(brakes,65);
      digitalWrite(fog,HIGH); 
      }
    if ((data[1]=='2')&&((data[0]=='4')||(data[0]=='5')||(data[0]=='6'))) { //BEAM on w FOG w/o BRAKES
      digitalWrite(beam,HIGH);
      analogWrite(brakes,255);
      digitalWrite(fog,HIGH); 
      }
     
   if (data[1]=='3') { //cam full left
     cam = 0;
      }
   if (data[1]=='4') { //Cam front left
     cam = 45;
      }
   if (data[1]=='5') { //Cam full front
     cam = 88;
      }
       if (data[1]=='6') { //Cam front right
     cam = 135;
      }
       if (data[1]=='7') { //cam full right
     cam = 180;
      }
      if (data[2]=='9') { //ALL FLASHER off
        digitalWrite(flashleft,LOW);
        digitalWrite(flashright,LOW);
        }
      if (data[2]=='1') { //LEFT FLASHER on
        digitalWrite(flashright,LOW);
        digitalWrite(flashleft,HIGH);
        }
      if (data[2]=='2') { //RIGHT FLASHER on
        digitalWrite(flashleft,LOW);
        digitalWrite(flashright,HIGH);
        }
   
         if (data[3]=='9'){ //turn off horn
         digitalWrite(horn,LOW);
         }
        
        if  (data[3]=='1'){ //turn on horn
        digitalWrite(horn,HIGH);
        }
        
}

full souce and app for the project

BatchFile
winrar executable with source code and visual basic 6 installer and arduino installer
4shared download link : https://www.4shared.com/file/lv1vmTXOba/build_2016-08-08-19h25.html
No preview (download only).

Credits

Luc Francoeur

Luc Francoeur

1 project • 2 followers

Comments