Introduction: I-Trash Car Prototype

i-Trash Car Prototype is an interfacing servo and DC motor in to ATMega8535, we use PING Sensor as ultrasonic sensor to detect a distance between trash and toy car.

Toy car will getting closer if Ping sensor detected any trash surround it's drive area.

Step 1: Preparation

Prepare some material that will be used at this project such as :

  • Toy Car
  • CV AVR Module
  • PING ))) Sensor
  • Rainbow Cable
  • Cable Tie
  • Capasitor 100uF/50V
  • IC L293D
  • Pin Header
  • Gearbox (double motor DC)
  • Servo Motor
  • Glue
  • Pencil Colour
  • Screwdriver
  • Beaverboard
  • wire nippers

Step 2: Mechanical Construction

You should understand perfectly where will you put gearbox, then where will you put Servo motor which and make sure that the construction is good looking and all of the components in good funtion too.

Step 3: Programming Step

In this project, you should make 4 program for interfacing on to DC Motor, Servo Motor, PING Sensor, and LCD Screen.

The Program can be like these

#include <mega8535.h>
#include <delay.h>

#include <alcd.h>

#include <stdio.h>

#define DDR_PING DDRB.0

#define PORT_PING PORTB.0

#define PIN_PING PINB.0

int i, j, k; unsigned char kata[16];

float jarak;

int baca_jarak()

{

unsigned int hitung=0;

DDR_PING=1;

PORT_PING=1;

delay_us(5);

PORT_PING=0;

DDR_PING=0;

PORT_PING=1;

while (PIN_PING==0) { }

while (PIN_PING==1)

{

hitung++;

delay_us(1);

}

jarak=(unsigned int)(((float)hitung)/25);

return(jarak); }

void putar_servo(void)

{

for(k=1; k<=27; k++)

{

PORTA.7=1;

for (j=1; j<=i; j++)

delay_us(10);

PORTA.7=0;

TIFR&=0x40;

TCNT2=0xB1;

while(!(TIFR&=0x40));

TIFR&=0x40;

}

}

void main (void)

{

PORTA=0x00;

DDRA=0xFF;

PORTC=0x00;

DDRC=0xFF;

PORTD=0x00;

DDRD=0xff;

TCCR2=0x07;

ASSR=0x00;

lcd_init(16);

while (1)

{

sprintf(kata, "%3d cm",baca_jarak());

if(jarak<=29)

{

PORTD.3 = 1;

PORTD.4 = 0;

lcd_clear();

sprintf(kata, "%3d cm", baca_jarak());

lcd_gotoxy(0,0);

lcd_puts(kata);

lcd_gotoxy(0,1);

lcd_puts(" TRASH ");

delay_ms(100);

}

if (jarak>=30)

{

PORTD.3 = 0;

lcd_clear();

lcd_gotoxy(0,0);

lcd_puts("TRASH");

lcd_gotoxy(0,1);

lcd_puts("DETECTED");

delay_ms(100);

i=205;

putar_servo();

PORTD.3=1;

delay_ms(1000);

PORTD.3=0;

i=45;

putar_servo();

}

}

}

Step 4: Wiring Step

After you finished to make program at Code Vision AVR, you should do some wiring. You can look at the Manual Book of Microcontroller book how to wire DC Motor at ATMega8535 module, and how to configure ping sensor for this project

Step 5: Troubleshooting

If you find any malfunction of each component, you can test the program one by one and make sure that every part of your i-Trash Car was succesfully assemblied

Step 6: Finishing

You can test your project.

Gearbox will give power to the back wheel to rotate, then ping sensor will detected trash that would be found in for about 100 cm distance, then servo motor will put down it's hand and take the trash. Afterthat it will put the trash in to the basket. Ping sensor will detected any trash again surrounding drive area directly.

Explore Science Contest

Participated in the
Explore Science Contest