Coding robots with text programming in a primary school

I love robot coding. The robots we use all have 2 motors which can only go forwards or backwards at variable speeds. The code is easy to understand.

These are some examples of KS2 children coding robots with text programming.

digitalWrite (7,HIGH); // makes motor 1 go forward

analogWrite (9,255); // gives motor 1 full power

digitalWrite (8,HIGH); //makes motor 2 go forward

analogWrite (10,255); // gives motor 2 full power

Add a delay between these steps and you’ve got full control. You can teach sequences.

Go forward  full power

After 5 seconds – STOP

After 2 seconds – turn right (1 forward, 2 backward)

After 3 seconds, – STOP

After 2 seconds – Go Backward, full power

After 2 seconds – STOP

Upload the code and away you go. It’s great for teaching sequences and logic.

 

Be Sociable, Share!

Leave a Reply