|
1 | 1 | #Import ElectroBlocks library |
2 | 2 | from electroblocks import ElectroBlocks |
3 | | -import time # imports the time library |
4 | 3 |
|
| 4 | +# Initialise the program settings and configurations |
| 5 | +eb = ElectroBlocks() # Create an instance of the ElectroBlocks class |
| 6 | +eb.config_joystick("A1", "A3", 9) # Configures the joystick |
| 7 | +eb.digital_write_config(7) |
| 8 | +eb.digital_write_config(8) |
| 9 | +eb.digital_write_config(13) |
5 | 10 |
|
6 | | -# Variable Declaration |
7 | 11 |
|
8 | | -# Initialise the program settings and configurations |
9 | | -eb = ElectroBlocks(verbose=True) # Create an instance of the ElectroBlocks class |
10 | | -eb.config_joystick("A1", "A3", 9) # Configures the LCD Screen pins |
11 | 12 |
|
12 | | -for _ in range(1, 10): |
13 | | - button_pressed = eb.is_joystick_button_pressed() |
14 | | - angle = eb.joystick_angle() |
15 | | - is_engaged = eb.is_joystick_engaged() |
16 | | - print(f"Engaged: {is_engaged} | Angle: {angle} | Button Pressed: {button_pressed}") |
17 | | - time.sleep(2) |
18 | | - print("CONTINUE") |
| 13 | +while True: |
| 14 | + if eb.is_joystick_button_pressed(): |
| 15 | + eb.digital_write(7, 1) # Turns the led on |
| 16 | + else: |
| 17 | + eb.digital_write(7, 0) # Turns the led off |
| 18 | + |
| 19 | + if (eb.joystick_angle() < 100): |
| 20 | + eb.digital_write(8, 0) # Turns the led off |
| 21 | + |
| 22 | + if (eb.joystick_angle() > 100): |
| 23 | + eb.digital_write(8, 1) # Turns the led on |
| 24 | + |
| 25 | + if eb.is_joystick_engaged(): |
| 26 | + eb.digital_write(13, 1) # Turns the led on |
| 27 | + else: |
| 28 | + eb.digital_write(13, 0) # Turns the led off |
0 commit comments