# Write your code here :-)
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""CircuitPython Essentials Servo standard servo example"""
import time
import board
import pwmio
import neopixel
import microcontroller
from adafruit_motor import servo
from adafruit_circuitplayground import cp

# create a PWMOut object on Pin A2.
pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)

# Create a servo object, my_servo.
my_servo = servo.Servo(pwm)


cp.pixels.brightness = 0.3
cp.pixels.fill((0, 0, 0))  # Turn off the NeoPixels if they're on!

timer = 60


while True:

    farenheitTemp = cp.temperature * 1.8 + 32
    print(farenheitTemp)

    if(farenheitTemp >= 76 and farenheitTemp < 78):
        cp.pixels[0:2] = [(255, 0,0)] * 2
    elif(farenheitTemp >= 78 and farenheitTemp < 80):
        cp.pixels[0:4] = [(255, 0,0)] * 4
    elif(farenheitTemp >= 80 and farenheitTemp < 82):
        cp.pixels[0:6] = [(255, 0,0)] * 6
    elif(farenheitTemp >= 82 and farenheitTemp < 84):
        cp.pixels[0:8] = [(255, 0,0)] * 8
    elif(farenheitTemp >= 84 and farenheitTemp < 86):
        cp.pixels[0:10] = [(255, 0,0)] * 10

    if cp.button_a:
        time.sleep(timer)
        cp.play_tone(262, 1)
        cp.play_tone(294, 1)
        cp.play_tone(262, 1)
        cp.play_tone(294, 1)


    if cp.button_b:
        timer = timer + 60





