معماری
Home / Do It Yourself / Yanny or Laurel robot #yannyorlaurel @adafruit #adafruit #CRICKIT « Adafruit Industries – Makers, hackers, artists, designers and engineers!

Yanny or Laurel robot #yannyorlaurel @adafruit #adafruit #CRICKIT « Adafruit Industries – Makers, hackers, artists, designers and engineers!


Yanny or Laurel robot (video), we had about 1 more hour before this meme expires, so we made a voting bot, it says the word, logs to csv, moves head, has clickable, light up buttons, it’s a voting machine.. Made with Adafruit CRICKIT, code is here.


# CircuitPython 3.0 CRICKIT demo

from adafruit_seesaw.seesaw import Seesaw

from adafruit_seesaw.pwmout import PWMOut

from adafruit_motor import servo

from busio import I2C

import audioio

import microcontroller

import board

import time



i2c = I2C(board.SCL, board.SDA)

ss = Seesaw(i2c)



print("Yanny or Laurel data logging!")



LOOKATPERSON = 90

LOOKLEFT = 60

LOOKRIGHT = 120



#################### 1 Servo

pwm = PWMOut(ss, 17)

pwm.frequency = 50

myservo = servo.Servo(pwm)

myservo.angle = LOOKATPERSON # introduce yourself



#################### 2 buttons w/2 LEDs

BUTTON_1 = 2

BUTTON_2 = 3

LED_1    = 8

LED_2    = 9



# Two buttons are pullups, connect to ground to activate

ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)

ss.pin_mode(BUTTON_2, ss.INPUT_PULLUP)

# Two LEDs are outputs, on by default

ss.pin_mode(LED_1, ss.OUTPUT)

ss.pin_mode(LED_2, ss.OUTPUT)

ss.digital_write(LED_1, True)

ss.digital_write(LED_2, True)



#################### log files

logfile = "/log.csv"

# check that we could append if wanted to

try:

    fp = open(logfile, "a")

    fp.close

except:

    print("File system not writable, halting")

    while True:

	pass



#################### Audio files

wavfile = "yanny.wav"

f = open(wavfile, "rb")

wav = audioio.WaveFile(f)

a = audioio.AudioOut(board.A0)

a.play(wav)

t = time.monotonic()



# Wait

while time.monotonic() - t  15.5:

		a.pause()



# now we have a selection!

with open(logfile, "a") as fp:

    print("Writing!"+selection+", 1n")

    fp.write(selection+", 1n")

    fp.flush()

print("Written")



# OK play the rest of the music

a.resume()

while a.playing:

    pass



ss.digital_write(LED_1, False)

ss.digital_write(LED_2, False)



microcontroller.reset()



Related:
We Made a Tool So You Can Hear Both Yanny and Laurel – The New York Times.

Get the only spam-free daily newsletter about wearables, running a “maker business”, electronic tips and more! Subscribe at AdafruitDaily.com !

No comments yet.

Adafruit has a “be excellent to each other” comment policy. Help us keep the community here positive and helpful. Stick to the topic, be respectful of makers of all ages and skill levels. Be kind, and don’t spam – Thank you!

Read Automatic By TracePress.com Company
if this Post need Change Tell Us!

About sara

Check Also

SFO’s Terminal 1 to Be Renamed After Harvey Milk

May 22, 2018 AT 12:30 am SFO’s Terminal 1 to Be Renamed After Harvey Milk …

Leave a Reply

Your email address will not be published. Required fields are marked *

قالب وردپرس