Summer Library for Arduino Author: Alexander Brevig Contact: alexanderbrevig@gmail.com
1.0 2008-10-23: Initial Release
1.0 2008-10-23: Initial Release
Summer is a library for the Arduino.
It is created to help Hardware Abstraction, and readability of code. It hides the pinMode, and digitalRead calls for the user.
Summer library is part of the Hardware Abstraction libraries.
Download here: Attach:Summer.zip
Put the Summer folder in "hardware\libraries\".
In the Arduino IDE, create a new sketch (or open one) and
select from the menubar "Sketch->Import Library->Summer".
Once the library is imported, an "#include Summer.h" line will appear
at the top of your Sketch.
Summer(uint8_t summerPin)
Summer summer = Summer(9);
Instanciates a Summer object at pin 9
Will execute the function it is referred to. In this case, the void blink()
Use PWM to generate a tone
Set tempo that are used by playTone:beats
Wrapper for playTone, with beat=1 : equivalent of playTone(toneFrequency,1)
Plays a frequency over a period of time indicated as beats at a given tempo.
/* || || @author Alexander Brevig || @version 1.0 || || @description || Demonstrates the functionality of the Summer class || Alternate between A4 and A5, playing A5 twice as long || */ #include <Summer.h> Summer summer = Summer(9); void setup() { summer.setTempo(300); } void loop() { summer.playTone(440,1); //A4 summer.playTone(880,2); //A5 }
How can I use multiple Summers?
Summer is a class. Therefore to Summer multiple digital pins, you must create an instance for each of them. In the example above, a Summer instance (Summer summer) is bound to the digital pin 9
Summer summer = Summer(9);
To add a Summer bound to digital pin 6, you could create the following instance summer2:
Summer summer2 = Summer(6);
And now it's just to use whatever function is wanted on both:
//update instances and possibly fire funcitons summer1.beep(440); //A4 summer2.playTone(880,2); //A5
Part of AlphaBeta Libraries. | |
Last Modified: | December 26, 2015, at 11:22 PM |
By: | pert |