Amplificador Marshall – Itinerario de aprendizaje proyecto 4

Nuestro Itinerario de aprendizaje maker esta desarrollado para aprender todos los fundamentos y un poco más acerca de electrónica y programación.

Si completas el itinerario serás capaz de crear casi cualquier proyecto que imagines. En cada proyecto se introducen nuevos conceptos, de modo que aprenderás haciendo o creando de una manera amena y divertida.

Utiliza un zumbador para que tus creaciones suenen con distintos tonos, ¡o melodias!

Project Description
Project 4
MARSHALL STYLE AMPLIFIER

Learn to make sounds, play with musical notes, make some noise or even a theremin!

Before Start
BEFORE TO START

DIFFICULTY LEVEL: Beginner
DURATION OF THE ACTIVITY: 40 min.

MATERIALS:
4in1 board
Buzzer
Button
Potentiometer
Battery holder & wires
Battery holder & wires

Battery holder, USB cable and wires.

Components
4 - Marshall amplifier - Components

The Buzzer is a module that puts out noise, also called Piezoelectric Speaker.It’s not like a regular speaker that you might think of. It changes shape when you apply electricity to it and bend the metal back and forth, which in turn creates noise.

The faster you bend the material, the higher the pitch of the noise that’s produced. This rate is called frequency.

What do you think we are talking about? Analog or Digital module?

Yes! it's a digital module! With 'high' output it makes noise. To vary tone we generate a square wave, and it will change according wave frequency

In next exercises we will use also many components seen in previous activities:

Button
Potentiometer
LEDs
LDR
Exercise 4.1 - Circuit
4. Power on buzzer - Circuit

For first exercise you just need to connect buzzer and button modules. In next exercises you have to connect many more digital and analog devices. Find here the circuit with all connected.

Connect wires according colours from 4in1 board to components:

- A0 to Potentiometer module
- DIO4 to Button module

- DIO6 to Buzzer module
- DIO9 to Red LED module

Exercise 4.1 - Program
4.1 Power on buzzer - Program

There is a specific function we can use to make buzzer sound , tone in Arduino IDE or play with note block. With blocks we can directly define a musical note, in Arduino instead we have to put frequency for each note, using sintax tone(pin, frequency, duration)

Block Coding
Arduino Coding
int pulsador = 4;

void setup(){
  pinMode(pulsador, INPUT);  
}

void loop(){
  if (digitalRead(pulsador)){
    noTone(10);
  }else{
    tone(10, 452, 338);
    delay(200);
    tone(10, 65535, 338);
    delay(200);
  }  
}
Exercise 4.2 - Play music scale
4.2 Play musical scale

Here we show you how to play the musical scale, so if you know some song partiture, you can make your favourit song later! No excuses!

Block coding
Arduino code
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

int light = 9; 
int buzzer = 10;

void setup() {
  pinMode(light,INPUT);
  pinMode(buzzer,OUTPUT);
}


void loop() {
      if (digitalRead (4))
      {
        tone(buzzer,2093,0.25*1000);
        delay (200);        
        tone(buzzer,2349,0.25*1000);
        delay (200);        
        tone(buzzer,2637,0.25*1000);        
        delay (200);       
        tone(buzzer,2794,0.25*1000);      
        delay (200);        
        tone(buzzer,3136,0.25*1000);        
        delay (200);       
        tone(buzzer,3520,0.25*1000);       
        delay (200);      
        tone(buzzer,3951,0.25*1000);       
        delay (200); 
      }
      else
      {
        noTone (10);
      }
      
}

Yeah, if you are a bit bored just now, try to get the song "la cucaracha" or "happy birthday" , or any other you want to dance!!! You can find here notes and more documentation for playing melodies with Arduino IDE

Exercise 4.3 - Change tone with potentiometer
4.3 Change tone with potentiometer

We have played fixed notes defined in our programs, now we want to modify sound with an external device, a potentiometer, like a electronic synthesizer.

Block coding
Arduino code
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

float valor = A0+0;
int light = 9;
int buzzer = 6;

void setup() {
  // call the pin here
  pinMode(buzzer, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(valor, INPUT);
}

void loop(){
  valor = analogRead(A0+0);
  for(int count = 0; count < 1; count++){
    if(valor < 0 && valor > 128)
    {
      digitalWrite(light, 0);
      noTone(buzzer);
      delay(200);
    }
    if(valor < 256 && valor > 128)
    {
      digitalWrite(light, 1);
      tone(buzzer, 65, 0.5 * 1000);
      delay(200);
    }
    if(valor < 384 && valor > 256)
    {
      digitalWrite(light, 1);
      tone(buzzer, 147, 0.5 * 1000);
      delay(200);
    }
    if(valor < 512 && valor > 384)
    {
      digitalWrite(light, 1);
      tone(buzzer, 330, 0.5 * 1000);
      delay(200);
    }
    if(valor < 640 && valor > 512)
    {
      digitalWrite(light, 1);
      tone(buzzer, 698, 0.5 * 1000);
      delay(200);
    }
    if(valor > 768 && valor < 640)
    {
      digitalWrite(light, 1);
      tone(buzzer, 1568, 0.5 * 1000);
      delay(200);
    }
    if(valor < 896 && valor > 768)
    {
      digitalWrite(light, 1);
      tone(buzzer, 3951, 0.5 * 1000);
      delay(200);
    }
  }  
}

Here we defined a function dedicated to read the analog input (potentiometer) and according his value, assign a scale note.

Try another analog sensor you can use instead of potentiometer to get a working theremin!! We suggest to use the map function to get it working nicely.

Exercise 4.4 - Vehicle emergency siren
4.4 - Vehicle emergency siren

Now combine sound & light!! You can make a complete emergeny sound and light system.
We need to blink two leds consecutevely while playing two tones.

Block coding
Arduino code
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
int buzzer = 6;
int bottom = 4;
int light = 9;

void setup() {
  // podiendo los pines
  pinMode(buzzer, INPUT); 
  pinMode(bottom, INPUT);
  pinMode(light, OUTPUT);
}

void loop() {
  if(digitalRead(4)){
    for(int count = 0; count < 3; count++)
    {
      digitalWrite(light, HIGH);     
      tone(6, 523, 0.5 * 1000);
      delay(300);
      digitalWrite(light, LOW);
      tone(6, 3136, 0.5 * 1000);
      delay(300);
    }
  }
}

As a bonus track, you can find melody for "la cucaracha" song in next slide. If you prefer it in your "emergency" vehicle you just need to update your code.

Exercise 4.4.1 - Vehicle emergency -la cucaracha
4.4 - Vehicle emergency "la cucaracha" song

Use code below to hear "la cucaracha" song. If you do some searches in the web, you will find many melodies you can use you vehicle!

Block coding
Arduino code
int light = 9;
int buzzer = 6;
int bottom = 4;

void setup() {
  // put your setup code here, to run once:
  pinMode(light, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(bottom, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(bottom))
  {
    for(int count=0;count<1;count++)
    {
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2794,500);
      delay(200);
      tone(buzzer,3520,500);
      delay(500);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2794,500);
      delay(200);
      tone(buzzer,3520,500);
      delay(500);
      tone(buzzer,2794,500);
      delay(200);
      tone(buzzer,2794,500);
      delay(200);
      tone(buzzer,2637,500);
      delay(200);
      tone(buzzer,2637,500);
      delay(200);
      tone(buzzer,2349,500);
      delay(200);      
      tone(buzzer,2349,500);
      delay(200);      
      tone(buzzer,2093,500);
      delay(1000);  
      tone(buzzer,2093,500);
      delay(200);     
      tone(buzzer,2093,500);
      delay(200);   
      tone(buzzer,2093,500);
      delay(200);     
      tone(buzzer,2637,500);
      delay(200);      
      tone(buzzer,3136,500);
      delay(500);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2637,500);
      delay(200); 
      tone(buzzer,3136,500);
      delay(500);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,2349,500);
      delay(200);
      tone(buzzer,2093,500);
      delay(200);
      tone(buzzer,3951,500);
      delay(200);
      tone(buzzer,3520,500);
      delay(200);
      tone(buzzer,3136,500);
      delay(200);
      tone(buzzer,2794,500);
      delay(200);
      }
  }
  else
  {
    digitalWrite(light,HIGH);
    delay(200);
    digitalWrite(light,LOW);
    delay(200);
  }
}
Final project - Marshall style amplifier
Final project - Marshall style amplifier

Now you can build this nice Marshall style amplifier and make some noise!! Download cardboard template.

Block coding
Arduino code
float encendido = 0;
float potenciometro = 0;

void setup() {
  pinMode(A0,INPUT);
  pinMode(2,INPUT);
  pinMode(4,OUTPUT);
  pinMode(3,INPUT);
}

void loop() {
  potenciometro = analogRead(A0+0) / 4;
  if(digitalRead(2)){
      if(encendido == 0.000000){
          encendido = 1;
          digitalWrite(4,1);
      }else{
          encendido = 0;
          digitalWrite(4,0);
      }
      delay(700);

  }
  if(encendido == 1.000000){
      if(potenciometro < 35){
          tone(3,65,0.5*1000);
      }
      if((potenciometro > 35)  &&  (potenciometro < 70)){
          tone(3,73,0.5*1000);
      }
      if((potenciometro > 70)  &&  (potenciometro < 105)){
          tone(3,82,0.5*1000);
      }
      if((potenciometro > 105)  &&  (potenciometro < 140)){
          tone(3,87,0.5*1000);
      }
      if((potenciometro > 140)  &&  (potenciometro < 175)){
          tone(3,98,0.5*1000);
      }
      if((potenciometro > 175)  &&  (potenciometro < 210)){
          tone(3,110,0.5*1000);
      }
      if((potenciometro > 210)  &&  (potenciometro < 245)){
          tone(3,123,0.5*1000);
      }
  }
}
previous arrow
next arrow

El Mega Maker Kit te ofrece el todo el material que necesitas para completar el itinerario, pero si dispones de otro kit, también puedes realizar algunos proyectos. Te animamos a que los revises todos, o que compres los componentes que necesites. Puedes verificar que actividades puedes realizar en nuestra página del Itinerario de aprendizaje.

0 0
0
¿Hablamos?
Necesitas Ayuda
¿Te ayudamos? 🙂

El horario en línea actualmente es de lunes a viernes de 10:00 a 13:30 y de 16:00 a 18:30 (hora España GTM+1). Si lo prefieres puedes enviarnos un correo a info@eboticseducation.com