Git Product home page Git Product logo

attiny45-adc-pwm-i2c-raspberrypi's Introduction


Here's an ATtiny45 with one 10-bit ADC pin and two 8-bit PWM pins. The ADC is used to read the value of a potentiometer. One PWM pin is used to control a LED-driver, the other one a piezo buzzer.

The ATtiny is an I2C slave to a Raspberry Pi, which can read out the ATtiny's ADC and set/get the PWM. One PWM pin has a fixed frequency and the pulse width is modulated, this is used to dim the LED, the other PWM pin has a variable frequency, so that the buzzer can buzz at different frequencies. A second ADC could be added on the reset pin, but that would cause the chip not to be reprogrammable anymore.

The I2C communication seems to be unstable, as "IOError: [Errno 5] Input/output error" do occur every now and then. In the video you can notice this by a stuck note. ***

The Raspberry Pi is hosting a Twisted server which, when a certain page of it gets requested, runs the following sequence: Read the 10-bit ADC, divide it by 4 and write that value to the LED pin, then play a fixed sequence of 3 notes.

The ATtiny45 gets programmed live (no wiring need to be changed) through an Arduino UNO which has the ArduinoIDE sketch loaded onto it.

https://www.youtube.com/watch?v=QWF8_Mfo1ek

*** Apparently I managed to solve this issue. I added two 4.7k pull-up resistors to the i2c lines (no comment...) and lowered the baud rate to 28800. I got this value while trying to replace i2c with the SoftwareSerial library, and that baud rate was the only one giving the least ammount of errors on a serial line. I dropped the idea of using SoftwareSerial because it consumes too much RAM (ATtiny45 has only 256 bytes), leaving no decent ammount for the app itself.

temporary:  modprobe -r i2c_bcm2708; modprobe i2c_bcm2708 baudrate=28800;
persistent: echo options i2c_bcm2708 baudrate=28800 > /etc/modprobe.d/i2c.conf

attiny45-adc-pwm-i2c-raspberrypi's People

Contributors

danielfaust avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.