Tuesday 9 March 2010 photo 1/1
![]() ![]() ![]() |
Program? It's awesome. Lego-programmering är askul :D
Så ser mitt och jockes program ut so far.
#define THRESHOLD 50
#define LEFT SENSOR_3
#define FWD SENSOR_2
#define RIGHT SENSOR_1
#define MIC SENSOR_4
//Wheel A = Left
//Wheel B = Right
task main()
{
SetSensorLight (IN_1);
SetSensorLight (IN_2);
SetSensorLight (IN_3);
SetSensorSound (IN_4);
OnFwd(OUT_AB, 50);
while (true)
{
if (FWD < THRESHOLD)
{
OnRev(OUT_AB, 50);
until(FWD >= THRESHOLD);
OnFwd(OUT_A, 50);
OnRev(OUT_B, 1);
Wait(400);
OnFwd(OUT_AB, 50);
}
if (FWD&&LEFT < THRESHOLD)
{
OnFwd(OUT_A, 50);
OnRev(OUT_B, 50);
until(FWD&&LEFT >= THRESHOLD);
OnFwd(OUT_AB, 50);
}
if (FWD&&RIGHT < THRESHOLD)
{
OnFwd(OUT_B, 50);
OnRev(OUT_A, 50);
until(FWD&&RIGHT >= THRESHOLD);
OnFwd(OUT_AB, 50);
}
if (MIC > THRESHOLD)
{
OnRev(OUT_AB, 25);
Wait(400);
OnFwd(OUT_A, 50);
OnRev(OUT_B, 50);
Wait(400);
OnFwd(OUT_AB, 50);
}
}
}
#define LEFT SENSOR_3
#define FWD SENSOR_2
#define RIGHT SENSOR_1
#define MIC SENSOR_4
//Wheel A = Left
//Wheel B = Right
task main()
{
SetSensorLight (IN_1);
SetSensorLight (IN_2);
SetSensorLight (IN_3);
SetSensorSound (IN_4);
OnFwd(OUT_AB, 50);
while (true)
{
if (FWD < THRESHOLD)
{
OnRev(OUT_AB, 50);
until(FWD >= THRESHOLD);
OnFwd(OUT_A, 50);
OnRev(OUT_B, 1);
Wait(400);
OnFwd(OUT_AB, 50);
}
if (FWD&&LEFT < THRESHOLD)
{
OnFwd(OUT_A, 50);
OnRev(OUT_B, 50);
until(FWD&&LEFT >= THRESHOLD);
OnFwd(OUT_AB, 50);
}
if (FWD&&RIGHT < THRESHOLD)
{
OnFwd(OUT_B, 50);
OnRev(OUT_A, 50);
until(FWD&&RIGHT >= THRESHOLD);
OnFwd(OUT_AB, 50);
}
if (MIC > THRESHOLD)
{
OnRev(OUT_AB, 25);
Wait(400);
OnFwd(OUT_A, 50);
OnRev(OUT_B, 50);
Wait(400);
OnFwd(OUT_AB, 50);
}
}
}
Comment the photo
inte för mig iaf som jobbar med programmering :P
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Alla fattar nog det där, det tror jag verkligen :D
Möh poan, du är nörd <3
14 comments on this photo
Directlink:
http://dayviews.com/najenin/446945885/