Lesson Aims:
Make a robot react to 3 different event triggers
Identify how the design of a robot can affects its performance
A
|
M
|
S
|
Learning Aims (what the learner will be able to do)
|
/
|
Can explain how precede and mutex commands work in NXC
| ||
/
|
Identify the order of execution in NxC
| ||
/
|
Write readable code
| ||
/
|
Write quality code
| ||
/
|
Design ideas for robot
| ||
/
|
Understand the requirements for U14 A2 and U24 A3
|
Today I have been working on the code for the NXT robot. I had a few issues that I had to fix before I recorded it. I have learnt today about playing sounds from the robot while it is doing something in between.
A strength of today is that I have managed to finish off the program and commented it in detail and I have recorded however I need to edit them together. To improve, I will comment in more detail when I am going along making the code instead of making short notes that sometimes do not make sense.
Overall today has gone well and I pleased about finishing off the code and recording the robot. I also enjoyed the starter activity where we played the Lightbot game as it was interesting using different solutions for the levels. Below is the code from my impact sensor.
task impact_sensor() //Task for checking impact sensor { while(true) { if(SENSOR_1 == 1) //If the sensor is activated then the program under will run { Acquire(motorMutex); Off(OUT_AC); Wait(HalfSec); OnRevSync(OUT_AC,MaxSpeed ,0); //Reverse at max speed so it can be easily identified from the ultrasonic sensor Wait(HalfSec); PlayTone(500,700); Wait(300); PlayTone(1175,400); Wait(300); //Will play a tone then it will turn around PlayTone(1397,400); Wait(500); OnFwd(OUT_A, HalfSpeed); OnRev(OUT_C, HalfSpeed); //Does a 180 spin so it goes back in the direction it went in Wait(900); Off(OUT_AC); //Turn off motors and wait half a second before releasing the motors Wait(HalfSec); Release(motorMutex); } } }
No comments:
Post a Comment