Skip to content
Snippets Groups Projects
Commit 60f47785 authored by Rico Kanthatham's avatar Rico Kanthatham :clown:
Browse files

wk8 all code added

parent a0f2d27f
No related branches found
No related tags found
No related merge requests found
Pipeline #395818 passed
......@@ -36,7 +36,7 @@ I need to create 3 swatch/sample electronic circuits total
**Reverse Avalance Oscillator**
I have always wanted to work on sound electronics. Aside from playing with the ISD1820 Sound Module with an Arduino Uno...I actually breadboarded several Analog Oscillator circuits using just discrete electronic components.
I have always wanted to work on sound electronics. Aside from playing with the DF Miniplayer Module with an Arduino Uno...I actually breadboarded several Analog Oscillator circuits using just discrete electronic components.
Here is one such builds...a **Reverse Avalanche Oscillator** circuit using an Light Dependent Resistor (LDR) to modulate the pitch of the oscillation noise (I was moving my mobile phone backlight close to/farther away from the sensor).
......@@ -57,19 +57,69 @@ The circuit is built with the following components...
1x LED
1x 8ohm 4W Speaker
I can easily see that this simple circuit could be made 'soft' with conductive thread serving as wiring to connect the discrete electronics...and the speaker could be 'soft speakers' demonstrated by this week's lecturer.
I can easily see that this simple circuit could be made 'soft' with conductive thread serving as wiring to connect the discrete electronics...and the speaker could be 'soft speakers' demonstrated by this week's lecturer.
**DF Mini Player MP3 Module**
**DF Mini Player MP3 Module**
This module is connected to an Arduino Uno as follows...
I followed [this tutorial](https://www.youtube.com/watch?v=azcRVLsgWF0&t=204s) to learn to use the DF Miniplayer. This module is connected to an Arduino Uno as follows...
![Alt text](../images/week08/df01.jpg)
![Alt text](../images/week08/df02.jpg)
Using this code...
Using this code...which requires the download and installation of thhe DF Miniplayer library from [here](https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299). I downloaded 3 free MP3 files from the internet and saved them to the SD card that was inserted in the DF Miniplayer.
```
//DF Miniplayer + Arduino
//by Fair Electro
//refactored by Rico Kanthatham, Fabricademy 2023
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h" //required DF miniplayer library...download and install into Arduino IDE
#define playVolume 20
#define playTime 900
static const uint8_t TXpin = 2;
static const uint8_t RXpin = 3;
SoftwareSerial softareSerial(RXpin, TXpin); //create soft serial object and define pins
DFRobotDFPlayerMini player; //create a DF Miniplayer object
void setup() {
Serial.begin(9600);
softwareSerial.begin(9600);
Keyboard.begin();
if (player.begin(softwareSerial)) {
Serial.println("OK");
} else {
Serial.prinln("Connecting to DFPlayer Mini failed!");
}
}
void loop() {
if(Keyboard.press("1")){
player.volume(playVolume);
player.play(1); //play sound files on SD card in the order it is listed
delay(playTime);
}
if(Keyboard.press("2")){
player.volume(playVolume);
player.play(2); //play sound files on SD card in the order it is listed
delay(playTime);
}
if(Keyboard.press("3")){
player.volume(playVolume);
player.play(3); //play sound files on SD card in the order it is listed
delay(playTime);
}
}
```
......@@ -102,7 +152,47 @@ The circuit schematic looks like this...
Running this code...
```
/*
* CapitiveSense Library Demo Sketch
* Paul Badger 2008
* Uses a high value resistor e.g. 10M between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of foil/metal on this pin
*/
//refactored by Rico Kanthatham, Fabricademy 2023
#include <CapacitiveSensor.h>
CapacitiveSensor touchPad1 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
const int fanPin = 13;
//int fanState = 1;
void setup(){
Serial.begin(9600);
touchPad1.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
pinMode(fanPin, OUTPUT);
}
void loop(){
long start = millis();
long total1 = touchPad1.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.println(total1); // print sensor output 1
delay(10); // arbitrary delay to limit data to serial port
if (total1 > 500){
digitalWrite(fanPin, HIGH);
} else {
digitalWrite(fanPin, LOW);
}
}
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment