Examples - Electronic Bricks - Electronic Brick Rotary

Analog In / Out - Get user input with the Electronik Brick Rotary.

This program gives you a basic understanding how to deal with analog signals using the Rotary and Speaker Electronic Brick.

The Arduino can Read the Analog signal via the AD by the analog pin, and put out the analog signal by PWM pins. In Arduino there are 6 analog input pins from A0-A1, and there are 6 analog output pins: D3 D5 D6 D9 D10 D11.

Hardware Setup: We use a buzzer brick and a Rotary brick to demonstrate the analog input and output .Connect the buzzer to D9 connector and the rotary brick to A1 connector of chassis.

Result: when you rotate the rotary brick, the buzzer sound will change.

Analog Example
Example: Analog input and output / interaction
Rotate the rotary brick and make sound

int Rotary  = 1;             // define the Rotary for 1st Analog pin
int Buzzer = 9;              // define the Buzzer for 9th Digital pin which is also an Analog out pin
int val = 0;

void setup()


void loop()
        val = analogRead(Rotary); // read the Rotary analog value
        analogWrite(Buzzer,val);  // Write the analog value out to Buzzer