Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

need help with coding~~ROBOT

Status
Not open for further replies.

tuan_101

New Member
anyway i know there was a topic about this somewhere in the forum but it wasn't what i was looking for, i was given a project at school with programming a line tracking robot, the line is black. we're using a microprocessor the PIC16F628A,
I'm currently using a program call mikroC compiler programming in C code. im planning on using 3 sensors. the middle sensor is always on, and when either one of the sensors on the side goes off it would turn that direction (meaning that the robot has gone slightly off the black duct tape). what how am i going about on doing this? since, I'm very new on C coding and dont really have a clue. can someone show me a code that they've made in the past for this? or an example, or just how am i gonna get started on this. -_______-" i know im asking 2 much but i am hopless at programming.

P.S im running the program at 4.00 MHz in the clocking source for the setting of program.

_MCLRE_OFF - we do not need master reset input
_WDT_OFF - we turn off something called the "watchdog timer"
_LVP_OFF - we are NOT using "Low voltage programming"
_INTRC_OSC_NOCLKOUT - we want to use an internal Oscillator and not have this signal visible at the output pins.

all of that are the setting for my program so far
 
There has got to be code on the internet for a line following robot.

Try David Cook's Robot Room.

If you get started and have trouble with the code or hardware we can help. But you need to be a bit self starting.

3v0
 
my so caleld codeeeeeeeee~~~

u told me to put schemtic in 3vo, are schemtic = {} <--- those brackets?

#define forward 0b000000101
#define backward 10
#define left 9
#define right 6
#define stop 0

void main()
{
CMCON = 0x07;
TRISA = 0x00;
PORTA = 0x00;


// setup the PORT that is used by the motors - TRIS, CMCON, etc

while(1) {//ever loop

//forward
if(PORTB && PORTA);
PORTA.F4 = 0 ;
PORTA.F5 = 1 ;
PORTA.F6 = 0 ;
PORTA.F7 = 1 ;
delay_ms(1000)
}
//backward
if(!PORTB && PORTA);
PORTA.F4 = 0 ;
PORTA.F5 = 1 ;
PORTA.F6 = 0 ;
PORTA.F7 = 1 ;
delay_ms(1000)

//left
if(PORTB && !PORTA);
PORTA.F4 = 1 ;
PORTA.F5 = 0 ;
PORTA.F6 = 0 ;
PORTA.F7 = 1 ;
delay_ms(1000)

//right
if(PORTB && PORTA);
PORTA.F4 = 0 ;
PORTA.F5 = 1 ;
PORTA.F6 = 1 ;
PORTA.F7 = 0 ;
delay_ms(1000)
//stop
if!(PORTB && PORTA);
PORTA.F4 = 0 ;
PORTA.F5 = 0 ;
PORTA.F6 = 0 ;
PORTA.F7 = 0 ;
delay_ms(1000)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top