Project 03: Windmill

3-1

1. Overview

In this project, we are going to make a mini windmill.

2. Components

Img

Img

Img

Kidsuno Mainboard×1

Rotary Potentiometer×1

360°Servo×1

Img

Img

Img

Connection Wire×1

USB Cable×1

Lego Series×1

Img

3. Installation

Preparation:

Img

Step1:

Img

Step2:

Img

Step3:

Img

Step4:

Img

Step5:

Img

Step6:

Img

Step7:

Img

Step8:

Img

Step9:

Img

Step10:

Img

Step11:

Img

Step12:

Img

Step13:

Img

Step14:

Img

Step15:

Img

Step16:

Img

Step17:

Img

Step18:

Img

Step19:

Img

Step20:

Img

Step21:

Img

Step22:

Img

Complete:

Img

4. Read the Value of Rotary Potentiometer

Img

5. Programming Steps

Step 1:Wiring Diagram

Connect the kidsuno mainboard and computer via a USB cable, and connect the rotary potentiometer to the No.7 interface, the 360° servo to the G, V and D13 interface of the mainboard. The brown wire is connected to G, the red wire is connected to V and the orange wire is connected to D13.

Img

Step 2: Description of Building Blocks

Img

This block is used to read analog value of the specified pin (range: 0~1023).

Step 3:Write the Program

① Drag the instruction block Imgin the Events module to the script area.

Img

② Drag the instruction block Imgin the Serial module to the script area and take the baud rate 9600 as an example.

Img

③ Drag the instruction blockImg in the Pins module to the script area. Since the rotary potentiometer is connected to A0 of No.7 interface on the mainboard, then change the number 0 to A0.

Img

④ Drag the instruction block Imgin the Control module to the script area.

Img

⑤ Drag the instruction blockImg in the Serial module to the script area.

Img

⑥ Drag the instruction block Imgin the Pins module to the script area and put it into the block Img.

Img

⑦ Drag the instruction block Imgin the Control module to the script area and change the number 1 to 0.3.

Img

⑧ Complete Program

Img

Step 4:Test Result

ClickImgto upload the complete program to the kidsuno mainboard and power up, then click Img in the serial monitor area to set the baud rate to 9600. Then the serial monitor will print the value read by the rotary potentiometer. When the knob on the potentiometer is rotated in one direction, the analog value will gradually increase; otherwise, it will decrease.

Img

6. Rotary Potentiometer Controls Windmill to Rotate

Img

7. Programming Steps

Step1: Description of Building Blocks

Img

This block is a mapping block, and mapping is a way of mapping each element (called a “key”) in one data set to a unique element (called a “value”) in another set. This correspondence can be represented in the form of a key-value pair, where each key corresponds to a value.

For example: how does the analog value of the rotary potentiometer correspond to the rotation angle of the 360° servo?

Here you need to use “mapping module” to map the analog value (0 ~ 1023) to the rotation angle of the 360° servo (90 °~180°). After mapping, when the analog value is 0, the angle of the servo is 90°(won’t rotate), and when the analog value is 1023, the angle of the servo is 180° ( the servo speed is maximum), as shown below.

Img

Step2:Flow Chart

Set the 360° servo angle to 90°. When the knob on the potentiometer is rotated, the analog value of the potentiometer is mapped to the angle of the servo to control its speed.

Img

Step3:Add Servo Instruction Block

Img

Step4:Write the Program

① Find building blocks

(1)Img

(2)Img

(3)Img

(4)Img

(5)Img

(6)Img

② Complete Program

Img

Step5:Test Result

ClickImgto upload the complete program to the kidsuno mainboard and power up, then rotate the knob on the potentiometer by hand, and the speed of the windmill will gradually increase.

Img

8. Expansion Project

Img

The sample code is below:

Img