View Feed
group-icon
Robotics
Community of Robotics Enthusiasts: Discuss latest robots and questions with fellow robot lovers
608 Members
Join this group to post and comment.
magnatron
magnatron • Sep 24, 2011

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//////////////////
magnatron
magnatron • Sep 24, 2011
ps the compiler program used is arduino
Rupam Das
Rupam Das • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
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 • Sep 24, 2011
Library Robot

[video=youtube;Smx15eOFHXQ]https://www.youtube.com/watch?v=Smx15eOFHXQ[/video]
You might also be interested in this Video. LOL::
magnatron
magnatron • Sep 24, 2011
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 • Sep 24, 2011
Re: Library Robot

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

Share this content on your social channels -