Professional Documents
Culture Documents
Bagaimana Membina Robot Anda Sendiri
Bagaimana Membina Robot Anda Sendiri
Denyutan
jantung
Sistem
Perkumuhan
Deria
Pelaksana Arahan
Central Procession Unit (CPU)
Current Flows
5V DC Supply
Ground Potential
Output Pin Ports
Otak Central Procession Unit (CPU)
Makanan 5V DC Supply
Resistor
LED
Push Button
Ground
Vdd Supply
Resistor
LED
Push Button
Ground
Vdd
Resistor
LED
Push Resistor
Button Vdd
Vss
Push
LED
Tanpa mikro pengawal Button
Dengan mikropengawal
Input Output Pin
A2 A1
A3 A0
PORTA
A4 A7
A5 A6
Vss Vdd
B0 B7
B1 B6
PORTB
B2 B5
B3 B4
Sambungan Input Output Kepada Mikro pengawal
A2 A1
A3 A0
Vdd
A4 A7
Resistor A5 A6
Push
Vss Vdd
Button
B0 B7
B1 B6
B5 Resistor
B2
B3 B4
Green LED
ISYARAT DARI MIKRO PENGAWAL KEPADA LITAR
ELEKTRONIK
0V - 5V
B5 Resistor
Vdd
0
Resistor A5
1
Test LED
Push Button
Digital Logic Level
0V – 5V
2V-5V ------- Logic 1
0V-0.8V -------- Logic 0
A0
A1
A3
A2
Motor Right
Ini antara soalan yang selalu bermain dibenak
fikiran anda:
void main(void) // the main function where the program will start operating
{
// enter your code here
}
Define IO pin as input or output
Example
void main(void) // the main function where the program will start operating
{
TRISB = 0b00000000;
PORTB= 0b00000000;
while(1) {
RB3=1; // Turn on the TestLED
}
}
Turn on an LED and OFF in a never ending
loop
while(1){
RB3=1;
RB3=0;
}
__CONFIG(0x3F32);
#define _XTAL_FREQ 20000000
void main(void)
{
TRISB =0b00000000;
PORTB=0b00000000;
while(1) {
RB3=0;
__delay_ms(39);
RB3=1;
__delay_ms(39);
}
}
Connect a push button
Define TRISB
Draw Schematic
0 B1
while(RB1==1)
{
RB3=1;
}
do {
//code to run here
}
while (expression);
for (variable = initial value; expression;
variable = variable + value)
{
//code to run here while expression is true
}
while (expression)
for (variable = initial value; expression;
variable = variable + value)
{
//code to run here while expression is true
}
while (expression)
for (x=1; x<9; x= x+1)
{ RC3 =1}
if ( expression)
{
//code to run here while expression is true
}
if ( RB2==1)
{
//code to run here while expression is true
}
Relational Operators
> Greater than
>= Greater than or Equal to
< Less than
<= Less than or Equal to
== Equal to
!= Not Equal to
Logical Operations
& AND
| OR
^ XOR
~ 1’s complement
>> Right Shift
<< Left Shift
Challenge your self
1. Write a program that will make your
robot to move from point A to point B
with the fastest time possible.