Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Traffic Light System proposal

Here is a traffic light system based on Arduino that can be use in a 3-way ond 4-way intersections. It has an additional blinking orange led that is used to signal when the pedestrians can cross the street. The code is a little bit complicated but I think you can understand how it works, right?

Check out this video below to see how the traffic lights system is working.
The code is written based on 4 situations:
  1. the first traffic light (TF1) has the red signal and the pedestrians ON; the second one (TF2) has green ON.
  2. TF1 has red and yellow ON; TF2 has yellow ON
  3. TF1 is green now and TF2 is red and pedestrians ON
  4. TF1 is yellow and TF2 is red and yellow
The schematic is too easy, all you have to do is connect the leds in series with a 470Ω resistor between the ground and the Arduino pins mentioned in the code.
arduino traffic lights
Code of the Arduino Traffic Lights Sketch
// Source: http://www.electroschematics.com/10178/arduino-traffic-light-system/
int trafficLights1[] = {2,3,4,5};	// red, yellow, green, pedestrians led pins
int trafficLights2[] = {6,7,8,9};	// red, yellow, green, pedestrians led pins
int situations = 4;
int duration[] = {8000,3000,10000,3000}; // duration of each situation
long previousCars = 0;
long previousPeds = 0;
long interval = 300;	//blink interval for pedestrians
int ledState = LOW;
int state;
int i = 0;

void setup()
{
  for(int i = 0; i < 4; i++) {
	  pinMode(trafficLights1[i], OUTPUT);
	  pinMode(trafficLights2[i], OUTPUT);
  }
	Serial.begin(9600);
}

void loop()
{	
	unsigned long currentMillis = millis();		
	if(currentMillis - previousCars < duration[i]) {			
		situation(i);		
	} else { 
		previousCars = currentMillis; 
		if(i >= situations) {
			i = 0;
			} else {
			i++;
		}		
	}
}

void activateTrafficLight1(String lights, int pedestrians) 
{	
	for(int x = 0; x < 3; x++) 
	{
		if(lights[x] == '0') state = LOW;
		if(lights[x] == '1') state = HIGH;
		digitalWrite(trafficLights1[x], state);	
	}
	if(pedestrians == 1) {
		blinkPed(trafficLights1[3]);
	} else {
		digitalWrite(trafficLights1[3], LOW);
	}
}

void activateTrafficLight2(String lights, int pedestrians)
{	
	for(int x = 0; x < 3; x++)
	{
		if(lights[x] == '0') state = LOW;
		if(lights[x] == '1') state = HIGH;
		digitalWrite(trafficLights2[x], state);
	}
	if(pedestrians == 1) {
		blinkPed(trafficLights2[3]);
	} else {
		digitalWrite(trafficLights2[3], LOW);
	}
}

void situation(int i)
{
	switch(i){
		case 0: 
			activateTrafficLight1("100",1); // 100 means red ON, yellow OFF, green OFF
			activateTrafficLight2("001",0); // the second parameter is for pedestrians
			break;							// 1 is ON and 0 is OFF
		case 1: 
			activateTrafficLight1("110",0); // 110: red ON, yellow ON, green OFF
			activateTrafficLight2("010",0);
			break;	
		case 2: 
			activateTrafficLight1("001",0);
			activateTrafficLight2("100",1);
			break;
		case 3:	
			activateTrafficLight1("010",0);
			activateTrafficLight2("110",0);
			break;	
	}
}

void blinkPed(int ped) {
	unsigned long currentMillis = millis();
	if(currentMillis - previousPeds > interval) {		
		previousPeds = currentMillis;		
		if (ledState == LOW)
		ledState = HIGH;
		else
		ledState = LOW;
		digitalWrite(ped, ledState);
	}	
}

[ MAKING ] ULTRASOUND RANGE FINDER

  ULTRASOUND RANGE FINDER

Everybody knows the speed of the sound in the dry air is around 340 m/s. Send a short ultrasonic pulse at 40 Khz in the air, and try to listen to the echo. Of course you won't hear anything, but with an ultrasonic sensor the back pulse can be detected. If you know the time of the forth & back travel of the ultrasonic wave, you know the distance, divide the distance by two and you know the range from the ultrasonic sensor to the first obstacle in front of it.
Here we use an ultrasonic piezzo transmitter with its receiver, they are very efficient, easy to find and quite cheap.

Water level indicator

  Water level indicator

The Water Level Indicator employs a simple mechanism to detect and indicate the water level in an overhead tank or any other water container. The sensing is done by using a set of nine probes which are placed at nine different levels on the tank walls (with probe9 to probe1 placed in increasing order of height, common probe (i.e. a supply carrying probe) is placed at the base of the tank). The level 9 represents the “tank full” condition while level 1 represents the “tank empty” condition.
When the water-level is below the minimum detectable level (MDL), the seven segment displays is arranged to show the digit 1, indicating that the tank is empty, When the water reaches level1 (but is below level2) the connection between the probes gets completed (through the conducting medium – water) and the base voltage of transistor increases. This causes the base-emitter junction of transistor to get forward biased, this switches transistor from cut-off to conduction mode thus PIN (B0) of microcontroller is pulled to ground hence, the corresponding digit displayed by the seven segment display is 2. The similar mechanism applies to the detection of all the other levels. When the tank is full, all inputs to microcontroller become low and all its outputs go high. This causes the display shows a 9 also in this case a buzzer sound is given, thereby indicating a “tank full” condition.
Most water level indicators are equipped to indicate and detect only a single level. The Water Level Indicator implemented here can indicate up to nine such levels and the microcontroller displays the level number on a seven segment display. So, not only is the circuit capable of cautioning a person that the water tank has been filled up to a certain level, it also indicates that the water level has fallen below the minimum detectable level. This circuit is important in appliances such as the water cooler where there is a danger of motor-burnout when there is no water in the radiator used up also it can be used in fuel level indication

A Change to Google Code Download Service

Project Hosting on Google Code provides a free collaborative development environment for open source projects. Each project comes with its own member controls, Subversion/Mercurial/Git repository, issue tracker, wiki pages, and downloads service.

Downloads were implemented by Project Hosting on Google Code to enable open source projects to make their files available for public download. Unfortunately, downloads have become a source of abuse with a significant increase in incidents recently. Due to this increasing misuse of the service and a desire to keep our community safe and secure, we are deprecating downloads.

Starting today, existing projects that do not have any downloads and all new projects will not have the ability to create downloads. Existing projects with downloads will see no visible changes until January 14, 2014 and will no longer have the ability to create new downloads starting on January 15, 2014.  All existing downloads in these projects will continue to be accessible for the foreseeable future.

If your project is using downloads to host and distribute files and has a need to periodically create new downloads, we recommend you move your downloads to an alternate service like Google Drive before January 15, 2014. If you choose to move your files to Google Drive, check out our help article.
By Google Project Hosting

code line following using MBLAB program

Program Code : .
The program was written by using MBLAB program . In this program 2 PWM channels
are used to reduce engine speeds. For details, you can make contact with author
quoc_huy115@yahoo.com
*********************************************
void main(void)
{
unsigned char i;
TmrGen = 0x0;
System_Init(); // user.c
RunFlag = 0;
Sensors._byte = 0x0;
LED5_On();
if(RunFlag)
{
i = Sensors._byte & 0xF;
switch(i)
{
case 0b0000:
Stop();
break;
case 0b0110:
case 0b0010:
case 0b0100:
Run();
break;
case 0b1100:
case 0b1000:
Turn_Right();
break;
case 0b0011:
case 0b0001:
Turn_Left();
break;
}//end switch
}
else
}//end main
*************************************************

code for css gps fencing

Some Importantant links below with reports.just view the link below. if u want any project report just search any project on our search box
Arduino interesting projects:   
Arduino 30 simple and good projects 
Atmega projects lists
Android Electronics projects lists
Rf based Projects with report
engineering study notes 
GSM GPS based projects with report
Bluetooth based projects with reports

9.3 CODE
#include <16F876A.h>
#include <string.h>
#include <math.h>
#include <lcd.c>
#include <stdlib.h>
#fuses      HS,NOWDT,PROTECT,brownout,put
#use        delay  (clock=20000000)
#use        RS - 232  (baud = 4800, xmit=PIN_A1,rcv=PIN_A0,stream=GPS)

int count = 0;
byte data[92];
char lat[12];
char lngtd[12];
char tdata[12];
char valid_data[] = { ",A," };
char invalid_data[] = { ",V," };
char gprmc[] = { "GPRMC" };
double f_lat;
double f_lng;
double f_lat_ref;
double f_lng_ref;
double result;
double get_gps_distance(double lat1,double lng1,double lat2,double lng2)
{
 double dist;
 dist = 1.2609 * (sqrt(((lat2-lat1)*(lat2-lat1)) + ((lng2-lng1)*(lng2-lng1))));
 return(dist);
}

void get_GPS_data()
{
   while(1)
 {
      fgets(data,GPS);

      if(strstr(data,gprmc))    
      {
         break;
          }
   }
  }

void get_gps_field(byte buf[],int field)

   int i = 0;
   int j = 0;
   int count = 0;
 
   while(buf[i])
   {
      if(buf[i] == ',')
         count++;
      if(count == field)  //1
         break;
      i++;
    }
   i++;
   while(buf[i] != ',')
   {
      tdata[j] = buf[i];
      i++;
      j++;
   }
   tdata[j] = 0;
}

void main()
{
   unsigned long radius = 30;
   int system_on = 0;
      lcd_init(); 
      lcd_putc('\f');         //Clear LCD
   lcd_gotoxy(1,1);        // row-1, column-1
   printf(lcd_putc,"Virtual Fencing");
   lcd_gotoxy(1,2);
   printf(lcd_putc,"  S Y S T E M");
 
   //Microcontroller Health Check Start
   output_high(PIN_C0);
   output_high(PIN_C2);
   output_high(PIN_C3);
   delay_ms(500);
   output_low(PIN_C0);
   output_low(PIN_C2);
   output_low(PIN_C3);
   delay_ms(500);
   output_high(PIN_C0);
   output_high(PIN_C2);
   output_high(PIN_C3);
   delay_ms(500);
   output_low(PIN_C0);
   output_low(PIN_C2);
   output_low(PIN_C3);

   //Microcontroller Health Check END 
    while(1)
    {     
       get_GPS_data();          
       if(strstr(data,valid_data))  //Check for valid data. If the gps data contains ",A," then it's a valid data
      {
         output_low(PIN_C3);   //RED LED OFF
         output_high(PIN_C2);  //Green LED ON indicating valid data 
         delay_ms(500);
      }
      if(strstr(data,invalid_data))   //If the gps data contains ",V," then its invalid data
      {       
         output_high(PIN_C3); //RED LED On indicating invalid data
         output_low(PIN_C2);  //Green LED OFF
         delay_ms(500);
         continue;
      }
       get_gps_field(data,3);   //get lat
       strcpy(lat,tdata);
       get_gps_field(data,5);  //get lngtd
       strcpy(lngtd,tdata);
       f_lat = atof(lat);  //convert to float
       f_lng = atof(lngtd);
       lcd_putc('\f');
       lcd_gotoxy(1,1);
       printf(LCD_PUTC,"lat=%5.6f",f_lat);
       lcd_gotoxy(1,2);
       printf(LCD_PUTC,"lng=%5.6f",f_lng);
       delay_ms(1000);
             if(!input(PIN_C4)) //Select the radius on pressing pubsh button
    {
          radius = radius + 10;
          lcd_putc('\f');
          lcd_gotoxy(1,2);
          printf(LCD_PUTC,"Radius = %Lu ",radius);
          delay_ms(1000);
       }
     if(!input(PIN_C5)) //Select the center point (push button)
       {
          f_lat_ref = f_lat;
          f_lng_ref = f_lng;
          lcd_putc('\f');
          lcd_gotoxy(1,1);
          printf(LCD_PUTC," V-FENCING MODE");   
        
          system_on = 1;          //set the flag
          delay_ms(1000);
       }
     
       if(system_on)
       {
          result = get_gps_distance(f_lat_ref,f_lng_ref,f_lat,f_lng);
          lcd_putc('\f');
          lcd_gotoxy(1,1);
    printf(LCD_PUTC,"Distance: %.0f mtrs",result);
             lcd_gotoxy(1,2);
             printf(LCD_PUTC,"Radius = %Lu",radius);
        
          delay_ms(2000);
           if(result > radius)
          {
            output_high(PIN_C0);  //LED Indicator ON
            output_high(PIN_C7); // Shock Generator ON
            delay_ms(50);
            output_low(PIN_C7);  //Shock Generator OFF
            output_high(PIN_B0);  //Buzzer ON
          }
          else
          {
            output_low(PIN_C0); //Indicator OFF
            output_low(PIN_C7);  //Shock Generator OFF
            output_low(PIN_B0);  //Buzzer OFF
          }
       }
    }
}

Some Importantant links below with reports.just view the link below. if u want any project report just search any project on our search box
Arduino interesting projects:   
Arduino 30 simple and good projects 
Atmega projects lists
Android Electronics projects lists
Rf based Projects with report
engineering study notes 
GSM GPS based projects with report
Bluetooth based projects with reports

assembly code for line following robot, 89C2051,89C2051

The complete assembly code is as below


INCLUDE 89C2051.mc

'Defining constants
Forward EQU 67h
RightBack EQU 51h
LeftBack EQU 4Ah

    ORG 0000h

AJMP Main

    ORG 0030h

Main: 
     MOV P1,#00h                                'Disable Motor Driver
     MOV P3,#0FFh                              'Set P3 as input port to read sensor o/p 
     SETB P1.6                         'Make P1.6 to which switch is connected
                                                                 'an i/p
Start:
     JNB P1.6,Finish                               'Stop if switch at P1.6 is pressed
     MOV P1,#Forward
     CALL Delay                                      'Produce 0.05s delay
     JNB P3.2,R_Back                           'If Right Sensor at P3.2 is activated
                                                                 'bring right wheel back
Next: 
     MOV P1,#Forward
     CALL Delay
     JNB P3.3,L_Back                           'If Left Sensor at P3.3 is activated

                                                                 'bring left wheel back                 
Back:
     AJMP Start                                      'Repeat above operation

Finish:
     MOV P1,#00h                                'Disable Motor Driver

Again:
     SJMP Again                    'Loop forever

R_Back:
     MOV P1,#RightBack
     JNB P3.2,R_Back                           'Repeat if Right Sensor is still activated
     SJMP Next  

L_Back:
     MOV P1,#LeftBack
     JNB P3.3,L_Back                           'Repeat if Left Sensor is still activated
     SJMP Back

Delay:                                                    'Produces approx 0.05s delay
     MOV R0,#255
Time1: 
     MOV R1,#255
Time2:
     DJNZ R1,Time2
     DJNZ R0,Time1
     RET


    END

line following robot proposal


Searches related to proposal line following robot

instructables line following robot
line following robot wikipedia
line following robot nxt
automated line following robot
sandwich line following robot
line following robot youtube
line following robot without microcontroller
line following robot pdf



line following robot proposal


Abstract

The line following is a classic introductory robot design and requires minimal amount of resources. This robot uses Microcontroller control. This robot is intended to showcase basic sensor design and robot control system in the form of a small autonomous robot which can follow a black line over white surface.

            A proposal for a line following robots and their relevance to engineering and society is given.  A project design for a line following robot is presented and discussed.  The project description is given, as well as the project approach, experiments to be run, and a proposed schedule for completing the robot.

The vehicle is supposed to have a low-resolution sensors and actuator. The control requirement, however, is specified so as to keep the vehicle as close as possible to the center of the line. The controllability issues are investigated, A multiple IR sensor based control algorithm is investigated for straight as well as curved paths. Experimental result is shown to demonstrate the usefulness of our idea. .

 

 

Final report using iandroid,line following robot 

line following,code in assembly language ,89s59,89s52