SHIVA S R
Published © MIT

Traffic Control Using Machine Learning

We are adding intelligence to the present traffic light system.

AdvancedShowcase (no instructions)6,391
Traffic Control Using Machine Learning

Things used in this project

Story

Read more

Code

MACHINE LEARNING CODE FOR ARDUINO UNO

C#
int t=0,j,t1,t2,i,b[16],temp=0;
char a[16];
float s,sum=0,m=1,s1[15],d1;
void setup() 

{
 Serial.begin(9600); // put your setup code here, to run once:

}

void loop() 

{


i=0;
  
  // put your main code here, to run repeatedly:

t1= millis();
for(j=0;j<15;j++)
{
for(i=0;t2<=t1+2;i++)
{
if(Serial.available()>0)
{
  a[i]=Serial.read();
 // i++;

 t2=millis();
}
}

b[j]=i;
}


for(i=0;i<15;i++)
{
  s=s+b[i]-i*2-b[0];
  d1=d1+b[i]-(i-0.2)*2-b[0];
}

m=1;
if(s<d1)
{
  for(i=0;temp==1;i++)
  {
    t=0;
  for(j=0;j<15;j++)
  {
   
   s1[i]=s1[i]+b[j]-m*t-b[0];
  t=t+2;


    
  }

   m=m+.2;
   
  if((i>0)&&(s1[i-1]<s1[i]))
    {
      temp=1;
      m=m-.2;

      
    }
  }


}



else if(s>d1)
{
  //same as befor where m=m-0.2

  for(i=0;temp==1;i++)
  {
    t=0;
  for(j=0;j<15;j++)
  {
   
   s1[i]=s1[i]+b[j]-m*t-b[0];
  t=t+2;


    
  }

   m=m-.2;
   
  if((i>0)&&(s1[i-1]<s1[i]))
    {
      temp=1;
      m=m+.2;

      
    }
  }

}


Serial.println(m);
Serial.println(b[0]);
}

Credits

SHIVA S R
2 projects • 9 followers
PASSION
Contact

Comments

Please log in or sign up to comment.