From 29b90b05593f25e6050c296a7eec542060e966c5 Mon Sep 17 00:00:00 2001 From: ef1g21 <ef1g21@soton.ac.uk> Date: Mon, 15 May 2023 01:05:30 +0000 Subject: [PATCH] Upload New File --- chooseAColour.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 chooseAColour.py diff --git a/chooseAColour.py b/chooseAColour.py new file mode 100644 index 0000000..08f9e11 --- /dev/null +++ b/chooseAColour.py @@ -0,0 +1,56 @@ + +from neopixel import Neopixel +import utime + +led = Neopixel(1, 0, 28, "RGB") # 1 LED, state machine 0, GP28 pin, RGB colour mode + +blue = (195, 0, 90) +red = (0,255, 0) +green = (255, 50, 0) +yellow = (255, 255, 0) +pink = (105, 255, 104) + + + + + + +while True: + print( "To switch off the LED enter 'off'") + print("Predefined colours are blue,red,green,yellow and pink") + user = input("Enter the colour if you want from predefined colours:" ) + user_input = user.strip() + print("You entered:", user_input) + + if user_input == "blue": + led.set_pixel(0, blue) + led.show() + + + elif user_input =="green": + led.set_pixel(0, green) + led.show() + + elif user_input =="red": + led.set_pixel(0, red) + led.show() + + elif user_input =="yellow": + led.set_pixel(0, yellow) + led.show() + + elif user_input =="off": + led.set_pixel(0, (0,0,0)) + led.show() + + elif user_input =="pink": + led.set_pixel(0, pink) + led.show() + + + + + + + + \ No newline at end of file -- GitLab