Code Monkey home page Code Monkey logo

thepihut3dxmastree-examples's Introduction

3dxmastree pihut3dxmastree thepihut3dxmastree

Alternatives

https://github.com/davesteele/pihut-xmas-asyncio

https://gist.github.com/rbnpi/5f5e9356e627d1cbc52086efbb56456c

The Pi Hut 3D Xmas Tree Examples

I tried to search for other examples of code but did not find anything relating to this specific The Pi Hut 3D Xmas tree one. There is the standard 'twinkle' example provided, and then some other buyers posted their code in the review section. Unfortunately the code from the reviews section is not indented, so it would not just run after copy and paste.

I copied all the examples I could find there and added them here, with full credits.

Why not setup a repository instead!? Lets share examples here, and then each Christmas we will have a lot of cool examples to choose from.

Contributing

Please consider contributing new examples into this repository. Provide some full credits if you found code else where and some basic description.

  • You can create an issue and label it more-examples
  • Fork the repository and add your own code and merge back here

Visit the Wiki to find more examples.

Setup

Please make sure to follow the setup instruction as on The Pi Hut site.

If you are having diffculties please look at the FAQ in the Wiki link

You can also run a full LED diagnostic program by running python diagnostics.py

Running the code

Make sure you have git installed.

If you're logging in with the default pi account, enter the following:

git clone https://github.com/ppumkin/thepihut3dxmastree-examples.git

This will pull the example code into the directory /home/pi/thepihut3dxmastree-examples/examples. If you use another account, the home directory name will change.

There is a simple script, 3dxmas.sh, which will present a menu of examples to run. You will need to install the dialog package, then run the script.

sudo apt install dialog
./3dxmas.sh

You can also run each example manaully, for example:

cd /home/pi/thepihut3dxmastree-examples/examples
python thepihut.py

Each example will block the console, so if you want you can add & and it fork into a new thread and keep running.

Autostart

The easiest way I found to get a Python script going was to use crontab.

Edit the file

sudo crontab -e

Add this line which tells cront to run this command once after reboot

@reboot python /home/pi/thepihut3dxmastree-examples/examples/thepihut.py &

Stop Autostart (or any other forked process)

If you want to stop the executing forked Python then you can use the following command to list all processes. Find the PID of your process (should be near bottom in the hundreds range) and then sudo kill <pid>

ps aux
sudo kill ####

2021 update

Hi there! Andy Piper (@andypiper) adjusted the code in this repo to bring it up-to-date for the latest Raspberry Pi OS distribution (based on Debian Bullseye), and to make it happier running with Python 3, which is now the default.

  • corrected typos
  • ran the Python 2to3 program over the samples
  • ran linters to format things nicely for readability
  • re-tested the examples

Note: I'm running an original pre-soldered 3D Xmas Tree (the non-RGB version), on a Pi Zero 1.2 (pre-wireless version), on the Bullseye version on Raspberry Pi OS Lite.

thepihut3dxmastree-examples's People

Contributors

andypiper avatar braxtondiggs avatar chrfritsch avatar glynm001 avatar herbfargus avatar p10tyr avatar williamhobbs avatar zilberd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

thepihut3dxmastree-examples's Issues

Python 3 Issues ?

Hi,

With the move to Bullseye, python 2 has been made obsolete, the examples here are all written for python 2 and will not run.

A really quick fix is to run the code through a small app that will convert simple py 2 code into py 3

sudo apt install 2to3

change into the examples directory

2to3 -w *.py

Hope this helps, happy Christmas !!

more-examples for the Pi Hut Tree

Here is my attempt at creating an application for the Pi Hut Xmas tree.

It creates 4 different sequences of the LEDs in a random order. Two sequences can go in reverse directions making 6 unique sequences. Each sequence runs for between 3 & 10 seconds.

I have also optionally modified my tree with a button between the otherwise unused GPIO3 & ground.
This is to provide a clean shutdown method when used in a stand-alone mode.
The button is wired between pins 5 & 6 of the GPIO connector on the tree.
It can take a while for the program to spot that the shutdown button has been pushed. So hold the button in until the light sequence stops.

It is my first attempt at coding in Python on Lynux so apologies if it is not very elegant.

I am also new to github as so I hope this works and you can find my code here:

https://github.com/GlynM001/Raspberry-pi-stuff/blob/master/xmas_tree_multi_random_function_VF2.py

A few ideas

I just got my tree and was looking for examples to get started learning and figured I'd try and contribute to something people have already started as opposed to starting my own.

Here are my thoughts:

  • Might be good to have a bit of a simple quick start guide/wiki just in case people find the pi hut docs lacking (I did!)
  • I want to get my tree to run with music, there are two ways of going about it, one is to have a mic/sound card where you play music and it reacts accordingly (eg http://lightshowpi.org/ more detailed guide of sorts here) or in my case I don't want to have to get extra hardware as I want the LED's to react to the audio output of my pi directly as opposed to listening for outside audio input, but I don't know if that's feasible at this point. still need to do more research. (see also
  • Morse Code: Type in a bit of text and have it blink the equivalent morse code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.