Question: Here's my code can someone help????????????/ In Python i'm trying to print a line on the LEDs that moves up and down when I use

Here's my code can someone help????????????/

In Python i'm trying to print a line on the LEDs that moves up and down when I use the Sense Hat motion (acceleration) but can't get it to work on raspberry pi

Please Help!

from sense_hat import SenseHat from time import sleep sense = SenseHat() sense.clear() r = (255,0,0) b = (0,0,0) w = (255,255,255) g = (0,255,0) accel_only = sense.get_accelerometer() print("p: {pitch}, r: {roll}, y: {yaw}".format(**accel_only)) y = 3 pixel_list = sense.get_pixels() sense.clear()

sense.set_pixel(0, y, g) sense.set_pixel(1, y, g) sense.set_pixel(2, y, g) sense.set_pixel(3, y, g) sense.set_pixel(4, y, g) sense.set_pixel(5, y, g) sense.set_pixel(6, y, g) sense.set_pixel(7, y, g)

def move_line(roll, y): new_y = y if 10 < roll < 170 and y != 7: new_y += 1 elif 350 > roll > 170 and y != 0 : new_y -= 1 return y

while True: pitch = sense.get_accelerometer() roll = sense.get_accelerometer() y = move_line(pitch, y)

from sense_hat import SenseHat from time import sleep sense = SenseHat() sense.clear() r = (255,0,0) b = (0,0,0) w = (255,255,255) g = (0,255,0) accel_only = sense.get_accelerometer() print("p: {pitch}, r: {roll}, y: {yaw}".format(**accel_only)) y = 3 pixel_list = sense.get_pixels() sense.clear()

sense.set_pixel(0, y, g) sense.set_pixel(1, y, g) sense.set_pixel(2, y, g) sense.set_pixel(3, y, g) sense.set_pixel(4, y, g) sense.set_pixel(5, y, g) sense.set_pixel(6, y, g) sense.set_pixel(7, y, g)

def move_line(roll, y): new_y = y if 10 < roll < 170 and y != 7: new_y += 1 elif 350 > roll > 170 and y != 0 : new_y -= 1 return y

while True: pitch = sense.get_accelerometer() roll = sense.get_accelerometer() y = move_line(pitch, y)

sense.set_pixels(pixel_list) sleep(1) move_line()

sense.set_pixels(pixel_list) sleep(1) move_line()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!