Society of Robots - Robot Forum

Software => Software => Topic started by: myblack60impala on April 30, 2007, 01:39:00 AM

Title: Here's some Bascom Basic code
Post by: myblack60impala on April 30, 2007, 01:39:00 AM
Here's some simple code for making a left wall following robot, using Bascom Basic. You might have to slightly modify it for your application, but its a great place for a new person to start.

Code: [Select]
' Code by F Johnston, use it to build a bot
'Follow left wall maze code, or it could be used with slight adjustments to make a line follower.
'
'This code requires the use of 3 IR sensors, a Barton board or a similar Atmel Mega 8 controller, and
'a skid steering platform.
'
$crystal = 1000000 'internal crystal
$regfile = "M8def.dat" 'micro config file
' Sensor ports are defined thus
' 1 = PINC.3 (Chan 3) Not used
' 2 = PINC.2 (Chan 2) Center_sensor
' 3 = PINC.1 (Chan 1) Left_sensor
' 4 = PINC.0 (Chan 0) Not used
' 5 = PINC.5 (Chan 5) Not used
' 6 = PINC.4 (Chan 4) Not used
Config Portb = Output
Config Portc = Output
Config Portd = Output
Config Timer1 = Pwm , Prescale = 8 , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
'
Declare Sub Bot_forward
Declare Sub Bot_reverse
Declare Sub Bot_stop
Declare Sub Bot_left
Declare Sub Bot_right
Declare Sub Bot_speed
'
Center_sensor Alias Pinc.2 'sensor port 2
Left_sensor Alias Pinc.1 'sensor port 3
M1a Alias Portd.0
M1b Alias Portd.1
M2a Alias Portd.2
M2b Alias Portd.3
M3a Alias Portd.4
M3b Alias Portd.5
M4a Alias Portb.7
M4b Alias Portb.6
Dim X As Byte
Dim Turn As Byte
Dim C As Byte
'
Goto Setup_done
'
Sub Bot_speed
Pwm1a = X
Pwm1b = X
End Sub
'
Sub Bot_forward
M3a = 1
M3b = 0
M4a = 1
M4b = 0
End Sub
'
Sub Bot_reverse
M3a = 0
M3b = 1
M4a = 0
M4b = 1
End Sub
'
Sub Bot_right
M3a = 1
M3b = 0
M4a = 0
M4b = 1
End Sub
'
Sub Bot_left
M3a = 0
M3b = 1
M4a = 1
M4b = 0
End Sub
'
Sub Bot_stop
M3a = 0
M3b = 0
M4a = 0
M4b = 0
End Sub
'
Setup_done:
'
Bot_speed
'
Wait 5
'
Do
Bot_forward
For X = 0 To 255 Step 1
Bot_speed
Waitms 100
Next X
 '
 ' follow left wall forward
 While Center_sensor = 1 And Left_sensor = 0
 Bot_forward
 Wait 500ms
 Wend
'
 ' turn left
 While Center_sensor = 1 And Left_sensor = 1
 Wait 250ms
 Bot_left
 Wait 500ms
 Wend
 '
     ' turn right
     While Center_sensor = 0 And Left_sensor = 0
     Wait 250ms
     Bot_right
     Wait 500ms
Loop
End
Title: Re: Here's some Bascom Basic code
Post by: g_monireh on April 28, 2012, 11:51:13 AM
Hello to all
I make a line follower robot but have problems in its source code.
I'm working with code vision and wrote the program using c language. I want Rbatm intersecting lines, raster, breaks, rings and ... But the simple code could only Bnvsm. I have no experience in the field of robotics and this is important for me and I need the source code if you code a line follower robot has developed a passion for me.
I'm not fluent in English and hard to write these sentences. Forgive me if it is wrong in this sentence.
Please send to my mail.
Thanks