simple robot suing asp.net and arduino.

#include char val; // Data received from the serial port


int motorPin1 =2;
int motorPin2 =3;
int motorPin3 =4;
int motorPin4 =5;


int addr = 0;


// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;
void setup() 
{
  pinMode(motorPin1, OUTPUT); // Set pin as OUTPUT
  pinMode(motorPin2, OUTPUT); // Set pin as OUTPUT
  pinMode(motorPin3, OUTPUT); // Set pin as OUTPUT
  pinMode(motorPin4, OUTPUT); // Set pin as OUTPUT
  Serial.begin(9600); // Start serial communication at 9600 bps
}


void loop() 
{
  if (Serial.available())
  { // If data is available to read,
    val = Serial.read(); // read it and store it in val
  }
  if (val == 'L') 
  { // If L was received
    digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, HIGH);
    digitalWrite(motorPin3, HIGH);
    digitalWrite(motorPin4, LOW);
    EEPROM.write(addr, 11);
  
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  addr = addr + 1;
  if (addr == 512)
    addr = 0;
    delay(50);
    
    
  } 
  if (val == 'R') 
  { // If R was received
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, HIGH); 
    EEPROM.write(addr, 10);
  
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  addr = addr + 1;
  if (addr == 512)
    addr = 0;
    delay(50);
    
  } 
  if (val == 'B') 
  { // If B was received
    digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, HIGH); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, HIGH);
    EEPROM.write(addr, 01);
  
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  addr = addr + 1;
  if (addr == 512)
    addr = 0;
   delay(50); 
  } 
  if (val == 'F') 
  { // If F was received
    digitalWrite(motorPin1, HIGH); 
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, HIGH); 
    digitalWrite(motorPin4, LOW);
    EEPROM.write(addr, 00);
  
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  addr = addr + 1;
  if (addr == 512)
    addr = 0;
    delay(50); 
  } 
  if (val == 'S') 
  { // If F was received
    digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, LOW); 
    EEPROM.write(addr, 100);
  
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  addr = addr + 1;
  if (addr == 512)
    addr = 0;
  } 
  if( val == 'R')
  {
    value = EEPROM.read(address); 
    if (value == 00)//fwrd
    {
       digitalWrite(motorPin1, HIGH); 
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, HIGH); 
    digitalWrite(motorPin4, LOW);
    delay(50);      
      
    }
    if (value == 01)//bckwrd
    
    {
       digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, HIGH); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, HIGH);
   delay(50); 
    }
    if (value == 10)//right
    
    {
     digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, HIGH); 
    delay(50);
    
    }
    if (value == 11)//left
    
    {
   digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, HIGH);
    digitalWrite(motorPin3, HIGH);
    digitalWrite(motorPin4, LOW);
    delay(50);
    
    }
    if (value == 100)// stop
    {
      
       digitalWrite(motorPin1, LOW); 
    digitalWrite(motorPin2, LOW); 
    digitalWrite(motorPin3, LOW); 
    digitalWrite(motorPin4, LOW); 
  
    }
    
      
    
    address = address + 1;
  
  // there are only 512 bytes of EEPROM, from 0 to 511, so if we're
  // on address 512, wrap around to address 0
  if (address == 512)
    address = 0;
    
  delay(500);
    
    
    
    
  }
  
  
  
}


circuit diagram : [​IMG]
pcb : [​IMG]
browser window: [​IMG]


/////////////////<3<3<3//////////////////

Replies

  • magnatron
    magnatron
    ps the compiler program used is arduino
  • Rupam Das
    Rupam Das
    Hello. I have Few doubts.

    That is the program that you burn in adruino. Right?
    How are you interfacing adruino with PC? Are you using USB or Parallel port.
    Could you share with us the block diagram and ASP.Net program that communicates with Adruino?
  • magnatron
    magnatron
    Rupam Das
    Hello. I have Few doubts.

    That is the program that you burn in adruino. Right?
    How are you interfacing adruino with PC? Are you using USB or Parallel port.
    Could you share with us the block diagram and ASP.Net program that communicates with Adruino?
    yeah.. actually its burnt into the AVR MCU i.e atmega xx its serial communication (UART), its just uses the inbuilt fuction for eg:

    Imports System.IO.Ports
    Partial Class Control
        Inherits System.Web.UI.Page
        Dim WithEvents serialPort1 As SerialPort
        Dim myString As String = ""
        Dim por As String
    
    
        Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
            Try
                Label1.Text = "Portselected  " & TextBox1.Text & " do not change the text(COM#) in textbox"
    
    
                serialPort1 = New System.IO.Ports.SerialPort(TextBox1.Text, 4800, Parity.None, 8, StopBits.One)
                serialPort1.Open()
                myString = "S"
                serialPort1.Write(myString)
                serialPort1.Close()
            Catch ex As Exception
                Label1.Text = ex.Message
    
    
            End Try
         
        End Sub
    
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Label1.Text = "Portselected  " & TextBox1.Text & " do not change the text(COM#) in textbox"
                serialPort1 = New System.IO.Ports.SerialPort(TextBox1.Text, 4800, Parity.None, 8, StopBits.One)
                serialPort1.Open()
                myString = "F"
                serialPort1.Write(myString)
                serialPort1.Close()
            Catch ex As Exception
                Label1.Text = ex.Message
    
    
            End Try
        End Sub
    
    
        Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
            Try
                Label1.Text = "Portselected  " & TextBox1.Text & " do not change the text(COM#) in textbox"
                serialPort1 = New System.IO.Ports.SerialPort(TextBox1.Text, 4800, Parity.None, 8, StopBits.One)
                serialPort1.Open()
                myString = "B"
                serialPort1.Write(myString)
                serialPort1.Close()
            Catch ex As Exception
                Label1.Text = ex.Message
    
    
            End Try
        End Sub
    
    
        Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
            Try
                Label1.Text = "Portselected  " & TextBox1.Text & " do not change the text(COM#) in textbox"
                serialPort1 = New System.IO.Ports.SerialPort(TextBox1.Text, 4800, Parity.None, 8, StopBits.One)
                serialPort1.Open()
                myString = "R"
                serialPort1.Write(myString)
                serialPort1.Close()
            Catch ex As Exception
                Label1.Text = ex.Message
    
    
            End Try
        End Sub
    
    
        Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
            Try
                Label1.Text = "Portselected  " & TextBox1.Text & " do not change the text(COM#) in textbox"
                serialPort1 = New System.IO.Ports.SerialPort(TextBox1.Text, 4800, Parity.None, 8, StopBits.One)
                serialPort1.Open()
                myString = "L"
                serialPort1.Write(myString)
                serialPort1.Close()
            Catch ex As Exception
                Label1.Text = ex.Message
    
    
            End Try
        End Sub
    
    
        Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
            por = TextBox1.Text
    
    
            Label1.Text = "Portset  " & por & "do not change the text(COM#) in textbox"
    
    
        End Sub
    
    
        Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    
    
        End Sub
    End Class
    
    
    
    
    
  • Rupam Das
    Rupam Das
    This is cool Stuff. Great work Dude. I am on my way. Putting it in Adruino and will convert it to C#, I am gonna replace ASP.Net with C#.net windows application. Will Interface Bluettoh and will post the video in CE in a week.
  • Rupam Das
    Rupam Das
    AND megatron, You are rocking. You are that gem of the source that we were missing that badly. Super work and keep posting. You are gonna make many fans in CE. I am your first one.
  • magnatron
    magnatron
    Rupam Das
    This is cool Stuff. Great work Dude. I am on my way. Putting it in Adruino and will convert it to C#, I am gonna replace ASP.Net with C#.net windows application. Will Interface Bluettoh and will post the video in CE in a week.
    do you have the Bluetooth shield of arduino? then its best ( i used a 433 MHz transmitter/receiver module) . the program is in vb (easier for me lol). try to make the interface first and just paste the code and compile.
  • magnatron
    magnatron
    Rupam Das
    AND megatron, You are rocking. You are that gem of the source that we were missing that badly. Super work and keep posting. You are gonna make many fans in CE. I am your first one.
    thanks! rupam! but i did'nt see any likes for my post (LOL just kidding)
    PS: its magnatron.. 😉 I will keep posting (majorly in lab section) i am a big dumb in theory😐 .
  • Rupam Das
    Rupam Das
    Web Server(Code)------------>Connected With robot
    |
    |
    |
    |
    |
    Command Given Through Web Page

    In that way, the robot is connected with Server. Physically considering that My Site is hosted remotely I would not be able to achieve It. Here is my Version

    Web Sever ( Web Service)------------------->Another Browser Connected with Robot Fetching the command and controlling
    |
    |
    |
    |
    |
    Web page calling the web service and putting the command
  • Rupam Das
    Rupam Das
    Library Robot

    [video=youtube;Smx15eOFHXQ]https://www.youtube.com/watch?v=Smx15eOFHXQ[/video]
    You might also be interested in this Video. LOL::
  • magnatron
    magnatron
    yeah, its done like that, but instead of publishing the web-service (for testing) what i did is to directly access the serial port of the computer. forgot to mention 😔
  • magnatron
    magnatron
    Re: Library Robot

    good video simple circuits (check out the counter using the black thingies LOL)

You are reading an archived discussion.

Related Posts

/*//////////////////////////////////// //////////Magnatron///////////////// //////////////////////////////////// ////magnatronelectronics@gmail.com// //////////////////////////////////// //////////////////////////////////// */ int val = 0; // variable to store the data from the serial port int serbyte = 0; int rlyPin1 = 13; int...
hey guys... i am not new to forms but new to this form... :O :bighug::bighug::bighug:
Hi i am 3rd year electronic and communication engg. I like to undergo some mini project . But i have no idea. Wat can i do?...
I looking for person who will do some project in Matlab. I need to project some electronic device, will be install between ECU and few sensors. Device should: - analyse...
Hi I am studying mechanical design and I have a few questions. What is the difference between a single-stage and a double-stage gearbox? How do you determine the number of...