Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A toy for my son
#1
So first a little bit of backgroud on me, Im pretty good with hardware, breadboards, and laying out circuits. I have not done much coding at all since the days of Quick Basic (Showing my age lol) Ive done a little but of C++ for arduino projects. My son is about 12 months and loves buttons that make sounds and light. So i boutght an Arcade joystick kit from amazon. It has a USB board that all the buttons and joy plug into so it acts as a usb joystick. The buttons light up. So my early plan is to us a Raspberry Pi, cut the wires toi the LEDs from the usb board (the lights are constantly on from it) and use the GIOP pins the light the buttons when he presses them and play a sound file. eventually I plan to add a neopixel matrix to show letters and patterns and such, but thast a ways out.right now im trying to workout how to poll the joystick and buttons and then send a high to a GIOP pin and play a sound file.

I've considered Pygame but Im not planning to have a monitor hooked up for now. also considered just skipping the usb board and going straight to GIOP but I would like to save the pins for other parts later. Also considered using an arduino to tke care of the buttons but will that really be any easier that usng the usb board?

THanks for any help and suggestions.
Reply
#2
There are different libraries to get access on input devices.

https://pypi.python.org/pypi/inputs

In the past I use a similar library, but I can't recognize the name. Something with ev... or eb...
But at the end all libraries for inputs do have the same structure.
You initialize an instance of the device. In a loop you're asking for incomming events like: x-axis, y-axis, buttons
Inside this loop you can handle also the other tasks.

You can also use threading or multiprocessing to do tasks, which could block the event loop.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
well, Im leaning more towards Python 3, and despite the page on our link saying it supports 3. when trying ether of the methods to install it, it onlys sets up the library for 2.7. Is there something im missing that sets it up in 3?
Reply
#4
(Mar-27-2018, 02:18 AM)RailRoaded Wrote: well, Im leaning more towards Python 3, and despite the page on our link saying it supports 3. when trying ether of the methods to install it, it onlys sets up the library for 2.7. Is there something im missing that sets it up in 3?

If you are referring to the RaspberryPi, a linux system when using Raspian, it comes with both Python 2 and Python 3 pre-installed. Because of that, you have to specify which you are referring to. When installing libraries the command pip install name will intall version 2, while the command pip3 install name will install version 3. The same holds true when invoking Python from the command terminal. Typing python will bring up the ver.2 terminal and typing python3 will bring up the ver.3 terminal.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#5
Thanks I'll try that tonight.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020