# data[].attributes.body
Please check for my code errors:

import event, halo, time

count=0

@event start

def_onstart

global_count

count=0

while true

count=count+1

halo.led.show_single(count,255,255,255)

time_sleep[1]

# data[].attributes.attachment_link.title
mBlock Block-Based IDE- Coding for Beginners

# data[].attributes.attachment_link.description
Start Learning coding with mBlock. Create with mBlock online block-based editor Today. Learn AI and robotic programming with mBlock.

# data[].attributes.body
import event, halo, time

@event.start

def on_start():

while True:

if halo.motion_sensor.is_tilted_left():

left_rainbow()

if halo.motion_sensor.is_tilted_right():

right_rainbow()

if halo.motion_sensor.is_arrow_up():

up_rainbow()

if halo.motion_sensor.is_arrow_down():

down_rainbow()

def left_rainbow ():

halo.led.show_ring('black black black black black purple blue cyan green yellow orange red')

def right_rainbow ():

halo.led.show_ring('orange yellow green cyan blue purple black black black black black red')

def up_rainbow ():

halo.led.show_ring('black black blue green orange red yellow cyan purple black black black')

def down_rainbow ():

halo.led.show_ring('orange green blue black black black black black purple cyan yellow red')

# data[].attributes.body
import event, halo, time

@event start

def on_start():

while True:

if halo.motion_sensor.get_pitch() > 70:

halo.led.show_ring('yellow black black yellow yellow yellow yellow yellow black black yellow black')

else:

halo.led.off_all()

# data[].attributes.body
import event, halo, time

jump_count = 0

@event.start

def on_start():

global jump_count

jump_count = 0

while True:

while not halo.motion_sensor.is_shaked():

pass

jump_count = jump_count + 1

halo.led.show_single(jump_count, 255, 0, 0)

time.sleep(1)

# data[].attributes.body
halo.pin0.play_tone(700,1)

____

halo.pin0  = pin 0 is connected. You can change to pin 1, 2, or 3 as well.

(700,1)   = the first number represents the frequency at which the sound is played.

The second number represents how many seconds the sound is played for.

# data[].attributes.body
import event, halo, time

jump_count = 0

@event.start

def on_start():

while True:

if halo.touchpad1.is_touched()

halo.pin0.servo_write(0)

if halo.touchpad2.is_touched()

halo.pin0.servo_write(180)

# data[].attributes.body
import event, halo, time

#initialize variables #this is a comment, and doesn't affect the code

WiperSpeed = 0

@event.start

def on_start():

global WiperSpeed

WiperSpeed = 2

while True:

if WiperSpeed == 0:

WiperSpeed = 2

halo.pin0.servo_write(0)

time.sleep(float(WiperSpeed))

halo.pin0.servo_write(180)

time.sleep(float(WiperSpeed))

@event.button_pressed

def on_button_pressed():

global WiperSpeed

WiperSpeed = WiperSpeed - 0.5

# data[].attributes.body
import event, halo, time

@event.button_pressed

def on_button_pressed():

halo.led.off_all()

while halo.pin2.read_analog() > 0:

print(halo.pin2.read_analog()) #this is to print/show the moisture level

if halo.pin2.read_analog() < 974:

halo.led.show_single(7, 255, 0, 0)

#include the rest of the code for the different moisture levels here

else halo.led.off_all()

# data[].attributes.body
import event, halo, time

@event.button_pressed

def on_button_pressed():

halo.led.off_all()

while True

if halo.pin2.read_digital() == 0:

for count in range(1):

halo.led.show_ring('red red white white white red red red white white white red')

halo.led.show_ring('red red white white white red red red white white white red',3)

# data[].attributes.body
You'll need to code the Halocode to respond to an input and respond with an output.

E.g detection of infrared sensor (detects movements) - causes Halocode to light up.

You can theme your project program around 3 themes as guidelines, convenience, security, efficiency.

E.g Convenience = The Halocode works as an automatic plant watering system.

The halocode is connected to a moisture sensor, which sends data about moisture levels to the halocode.

Below a certain moisture level, the halocode will turn the servo motor(which is connected to the watering can to tilt it, to water plants).

Security; The Halocode uses the IR sensor to detect incoming/objects close to the sensor and starts flashing red lights as a warning.
---

Remember that you can change your outputs and use the various lines of code to adjust the output you want.

# data[].attributes.body
For Moisture sensor

Moisture sensor - connector - connector - halocode
VCC to 3.3v
GND to GND
AO to Any Number Pin

Infrared Sensor - Halocode
VCC - 3.3v
GND - GND
OUT - Any numbered pin

SERVO MOTOR

RED WIRE - 3.3V
ORANGE WIRE - Any numbered pin
BROWN WIRE - GND

BUZZER

Long Pin on buzzer - any numbered pin
Short Pin on buzzer - GND