segunda-feira, 13 de fevereiro de 2012

Fritzing drawing and Arduino Code v5.0

Here is what I have already:

Fritzing drawing:







Arduino Code (v5.0 updated):


 // Ruete's Open Source Laser Harp v5.0
 // Free for home use. Comercial use proibited.
 // v5.0 updates:
 // frame expanded width
 // optmized settings for sensor
 // optimized settings for laser brightness and blanking

 // Circuito MIDI:
 // * digital in 1 conectado ao MIDI jack pin 5 (DO MIDI JACK)
 // * MIDI jack pin 2 conectado ao ground (DO ARDUINO)
 // * MIDI jack pin 4 (DO MIDI JACK) conectado ao +5V (DO ARDUINO) por um resistor de 220-ohm

int buttonPresses = 0; // quantas vezes a nota foi tocada

int LaserState = LOW; // laser "off"
int sensor = 8 ; // valor do sensor calibrado
int delayligado = 5; //minimo 2 para aparecer direito o laser
int delaymexe = 3; //delay entre movimentos minimo 3
int delaydesligado = 0; // minimo 0
long previousMillis = 0; // guarda ultima vez que o laser foi atualizado
const int LaserPin =  7; // define pin do arduino para o laser
long timer = 100; // intervalo que o laser vai pisca em milisegundos

int val = 100;

// define os pins do motor no arduino
int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;



int note9 = 0x33;  
int note8 = 0x32;   
int note7 = 0x30; 
int note6 = 0x2E; 
int note5 = 0x2C; 
int note4 = 0x2B; 
int note3 = 0x29; 
int note2 = 0x24; 
int note1 = 0x24;

// setup ------------------------------------------------------------
void setup()
{
 
 
  // do motor:
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
 
  // do laser:
  pinMode(LaserPin, OUTPUT);   
   
  // do led:
  pinMode(13, OUTPUT);

  //  ativa frequencia MIDI (baud rate):
  Serial.begin(31250);
}

void noteOn(int cmd, int pitch, int velocity)
  {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
  }
 
//-------------------------------------------------------------------------------------------
// inicio do loop ---------------------------------------------------------------------------
void loop()
{
 
 

// movimento horario ---------------------------------------------------------- 

digitalWrite(LaserPin, HIGH);    // liga laser 1
 delay(delayligado);
//********************************************************************************************************************************** 
if ( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note1, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note1, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************

 digitalWrite(LaserPin, LOW);    // desliga laser 1
 delay(delaydesligado);

//------------------------------------------------------------------- 
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 2
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW); 
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 3
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW); 
  delay(delaymexe); // espera o motor
 
  digitalWrite(LaserPin, HIGH);    // liga laser 2
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note2, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note2, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 2
 delay(delaydesligado);

//-------------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 4
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 5
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 3
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note3, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note3, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 3
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 6
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 7
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor

  digitalWrite(LaserPin, HIGH);    // liga laser 4
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note4, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note4, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 4
 delay(delaydesligado);

//-----------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 8
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 9
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 5
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note5, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note5, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 5
 delay(delaydesligado);

//-------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 10
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 11
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 6
   delay(delayligado);
 //********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note6, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note6, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 6
 delay(delaydesligado);

//------------------------------------------------------------------ 
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 12
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 13
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 7
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note7, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note7, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 7
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 14
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 15
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 8
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note8, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note8, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 8
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 16
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 17
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 9
   delay(delayligado);
//**********************************************************************************************************************************  ** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note9, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note9, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************


  digitalWrite(LaserPin, LOW);    // desliga laser 9
 delay(delaydesligado);

//-----------------------------------------------------------------------------
// movimento anti-horario ----------------------------------------------------- 

//------------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 16
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 15
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 8
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note8, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note8, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 8
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 14
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 13
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 7
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note7, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note7, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 7
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 13
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 12
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 6
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note6, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note6, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 6
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 11
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 10
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 5
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note5, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note5, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 5
 delay(delaydesligado);

//------------------------------------------------------------------ 
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 9
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 8
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 4
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note4, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note4, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 4
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 7
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 6
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 3
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note3, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note3, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 3
 delay(delaydesligado);

//-------------------------------------------------------------------
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 5
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 4
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
   
  digitalWrite(LaserPin, HIGH);    // liga laser 2
   delay(delayligado);
//********************************************************************************************************************************** 
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E  ainda nao começou a tocar entao toca a nota++++++++++++
         
             {
             // faça A -----------------------------------------------------------------------------------------------------------
             digitalWrite(13, HIGH);       // acende o led 
             noteOn(0x90, note2, 0x7F);    // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
             buttonPresses++;              // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
             }
          
// --------------------------------------------------------------------------------------------------------------------  
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
                  { // //  faça B = silencia a nota
                  digitalWrite(13, LOW);        // desliga o led  
                  noteOn(0x90, note2, 0x00);     // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
                  buttonPresses = 0;            // zera o "buttonPresses"
                  }       
//**********************************************************************************************************************************
  digitalWrite(LaserPin, LOW);    // desliga laser 2
 delay(delaydesligado);

//------------------------------------------------------------------
  digitalWrite(motorPin1, HIGH); // comanda o motor para mexer para 3
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delaymexe); // espera o motor
  digitalWrite(motorPin1, LOW); // comanda o motor para mexer para 2
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delaymexe); // espera o motor
 

    
}
// final do loop para mexer o motor e ligar/desligar laser (volta para o começo do loop)-----
//-------------------------------------------------------------------------------------------




Fell free to ask questions and contribute for a better project..


Have fun!



59 comentários:

Anônimo disse...

The stepper motor, does it have to be a 8 wire or can it be a 4 wire..? :)

Ruete disse...

Yes it can be a 4 wire stepper (or even a 5 wire). But it has got to be fast.
And you will need to wire it differently with the ULN2003.
It is not difficult. Just search google on how to drive a stepper with ULN2003.
If you cant find anything tell me and I can search my arquives and find somethign to help you.

Anônimo disse...

Thank you :) i will have alook and see what i can find and thank you in advance, if i can not find any answers, the only reason for asking about the stepper motor is the 8 wire is more expensive than 2,4,6 wired ones.. If you do have any more info in your arquives my email is harper_clive@yahoo.co.uk..
The items i have got are a 200mw dpss laser, Arduino Uno and a galvanometer from a old projector but the stepper motor looks better...

Ruete disse...

Hello my friend, I found something that might be useful for you concerning how to figure a step motor. Here is the link:

http://www.youtube.com/watch?v=fTtwWJZlGt4&feature=player_embedded

Anônimo disse...

Would that code (the midi area) still work with the LDR if a separate projector produces the beams with the LDR picking up the reflection as a separate circuit do you think..? :)

Anônimo disse...

Would the LDR area still work if a laser projector already has 8 beams..?

Ruete disse...

I am not sure I understand your question (english is not my native language...) Please ask that again in a different way. I will be happy to help.

Clive klein disse...

I have laser projector with 8 and 12 beams the Arduino code, will it still work if i use LDR circuit and no Stepper motor..? If you tell me your native language i will translate.. :)Is it Spanish.. :)

Clive klein disse...

Tenho laser projector 8 e 12 vigas que o Arduino ainda trabalhar para o LDR, sem o motor de passo que você acha .. :)

Ruete disse...

My native language is portuguese (Brasil). I understand a little spanish also.
I am still not sure if I understand what you mean, but here are some comments that might help:
1) If you mean that you already have a fixed laser it can work with some modifications. I did make a Laser Harp Version 1 with a diffraction lens. It had one laser going to a diffraction lens and it turned out about 12 or more fixed beams. The problem is I had to make a frame and use 12 sensors (one for each beam) to detect them.
And yes in this case you dont need a step motor.
If that is what you are talking about I can search for my old code that I used for Arduino as well as other tips for that and send (or publish here) for you.

Clive klein disse...

Sorry if this is wrong.. O meu laser se parece com uma harpa laser com os 8 e 12 vigas de feixe apenas com nenhum circuito de som por isso, se LDR circuito irá trabalhar a partir de seu projeto eu posso ter uma harpa laser de trabalhar .. (Any help you can give me i will be very greatful)

Clive klein disse...

My email is harper_clive@yahoo.co.uk :)

Clive klein disse...

Any help will be greatful :)

Ruete disse...

So you do want to make a fixed (framed) Laser Harp right?
SOmething like this:
http://makepgh.org/wp-content/uploads/2010/01/matt_laser_harp.jpg

P.S. What is your native language?

Ruete disse...

Here is the basic principle of a framed laser harp:

http://www.instructables.com/id/Arduino-Laser-Tripwire/?ALLSTEPS

You shine a laser into a LDR sensor and make the Arduino code play a MIDI note when you stop the beam.
To make a framed harp you must repeat this with 8 or 12 beams as you like.
Does that help?

Clive klein disse...

My native language is English :) I want to build frameless laser harp :)i have DPSS laser, Arduino, Galvo's :)

Clive klein disse...

My Laser i have http://www.dealport.co.uk/products/Animation-Laser-Projector-%252d-Green-Laser-Effects.html

Anônimo disse...

Eu quero construir uma harpa frameless i tenho a maioria dos pedaços de seu design :)

Ruete disse...

Constroi ai e manda um video dela q eu publico aqui!
Se precisa de ajuda manda uma mensagem.
Boa sorte!

rockernault disse...

I need some help with your design. I will make short sentences for you to understand.

1000mW laser loses power with 2N2222A on/off
laser pierde poder cuando transistor enciende y apaga. Poca potencia, aun usando 1W laser


Your stepper motor is fast? How fast is it?

Anônimo disse...

Hello,
I have a 4wire bipolar stepper motor.. Can it work with the same programe and a l293 ci? thank you

Ruete disse...

During testing phase I found out there are some things that may affect how bright the laser actually looks.

Here they are:

1) How long the program tells the laser to stay on before turning it off.
This can be adjusted in the beginning of the programing code (variable "delayligado")

int delayligado = 5; //minimo 2 para aparecer direito o laser

I tested using different numbers and 5 was the best for me.
You can try more or less.
5 means it will wait for 5 miliseconds after the laser turns on.
The minimum value to see the laser was 2 for me.
For example: if you want to use a 10 milisecond delay chage it to this:

int delayligado = 10; //minimo 2 para aparecer direito o laser


--
2) Some lasers sold in the internet states that they have 1000mW but the real power will not be that much for real. The only way I know how to measure this is to use a laser measuring device (too expensive for most of us...) Or try visiting a phisics lab department and ask if they have that measuroing device and if they could do you a favor and measure yours...)

3) I remember I also had some issues with my laser light sometimes shining less bright than others and that turned out to be bad contact from leads or weak baterry (when I was testing whith baterries)
----

About the motor it has to be fast. I dont know how much, but it seems that any of those small nema sold at ebay would work (solid metal case).
I beleave I used a nema 17.
Also they sell with different wire types. They will all work but you will have to search google to find out how to wire them. IN fact this one I used here was a little more complicated to figure out, but was the only one I was able to buy at the time.
The ones that will not work are those that are used for radio controled airplanes to move flaps etc (those plastic blue ones). These are too slow.

Ruete disse...

The weblink is not working. Please post that again.

Ruete disse...

Nao entendi bem o que voce quer dizer...
Esta falando de uma Harp Laser fixa (framed)?
Pode postar em ingles mesmo q eu respondo (se for sua lingua nativa)
Este projeto tem varios modulos juntos:
1) o que faz o motor girar
2) o que faz o laser acender e apagar
3) os LDR que leem se o laser esta aceso ou apagado
4) o Arduino com a programacao que cordena tudo isto.
Se quiser fazer uma harp laser fixa (framed) nao vai precisar do motor, mas vai ter que usar mais LDRs(um para cada feixe).

Ruete disse...

1) It can work with 8 beams. The LDR senses if the laser is on or off, and the program tells the arduino where the motor is at this time so it can decide what note it will play.
FOr the human eye it looks like all beams are lighted up at the same time, but in reality they are turned on/off at diferrent times. That the principle of how a frameless harp work.
Now if you want to make a framed harp that you will not need a stepper motor. But you will need more LDRs(one for each beam)

Ruete disse...

...I have a 4wire bipolar stepper motor.. Can it work with the same programe and a l293 ci? thank you

yes it can work with a 4 wire stepper. But you will have to wire it differently (the stepper)

Here is alink to help you figure out how to wire it:

http://www.youtube.com/watch?v=fTtwWJZlGt4&feature=player_embedded

2) ABout the i293 ci I dont know.. sorry...

Ruete disse...

How is your project going?

Ruete disse...

There is a way to make this work without the stepper motor, and that is you must use one LDR for each individual beam. Also the programing should be different.
I believe I posted here at this blog a link to a framed laser harp on how to do this.
It is a lot simpler, and bigger ;)
I have done one myself before moving for a frameless laser harp.

Ruete disse...

No, that code works with a stepper motor. It moves the motor, turns the laser on;off, reads the LDR state and decides what note to play (pedending on what place the stepper motor is at the time).
If you want to make a Laser Harp without a stepper motor it is a lot easyer. Just search google for framed laser harp. I believe Steve Hobley published a framed harp laser project in Make magazine.
Other people have published framed laser harps in the internet.
The diference is that you will have one LDR to detect each laser beam. They will be fixed in a frame, you will not need a stepper motor and the programing is diferent.

Dhruv Kapur disse...

Hey I need some help with my motor. I have a stepper with no data sheets with me, I have been able to drive it directly with Arduino as for now, but don't know how much speed do I need from it... any help on it will be greatly... And literally greatly appreciated... my email is dhruvkapur91@gmail.com

Ruete disse...

I had the same problem... My stepper had no data sheet. No problem. Youtube has tons of videos about how to figure out the wires.
I have posted in this blog a link already. But since you said you have been able to drive it from Arduino, I presume I dont need to post it again here for you.
So from what I understand your only concern is how fast it should be right?
I will share with you my thoughts and trial/error experience about that:
1) as far as I know the human eye is can see up to 30 frames per second (old movies are 30 frames per second).
(continue below)

Ruete disse...

(...continued)
2) I thought that if I wanted a 10 beam laser harp for example I should shine each beam 30 times per second.
Now there should be at least one black space between each beam, so add 9 spaces to that.
So 10+9=19 (Your motor should move to 19 positions x 30 times per second)
Thats 570 moves per second (19x30=570) in the range you need (not for a full rotation, just about 1/4 of a full rotation)
Hope that helps.

Dhruv Kapur disse...

Very^infinity thankful for your feedback on the motor part. Currently my motor is working at 300 steps per second. For now its enough to produce 4-5 beams.

However I am unable to work out the laser part. I took 200mW red laser from a DVD writer (20x) And luckily burnt it today :P Today I directly applied 4V across the diode for a few seconds and then it burnt out.

We'll get ourselves a new working diode soon (hopefully from a DVD writer only) but any guidance on working with it will be highly appreciated once again. Plus do we need some special driving circuits with it or not?

Thanks a lot...!!! :)

Ruete disse...
Este comentário foi removido pelo autor.
Ruete disse...

Just a reminder: be carefull with lasers. Always use safety goggles. It can really damage your eyes if it shines for a split second inside your eyes and you dont use them. Believe me it is worth to buy them.
Just search ebay.com for "laser safety goggles" and you will find them for less than US$10.
Here is an example of safety google for a green laser:

http://www.ebay.com/itm/Protection-Goggles-Laser-Safety-Glasses-Green-Blue-/110607705525?pt=LH_DefaultDomain_0&hash=item19c0bba5b5#ht_4983wt_934


About burning a laser, I have burned a couple of them too... :(
Try searching for laser forums and most of them have a section where they explain in detail how much power you should use for a laser.

Since I used a laser pen for this project, it was easy to just exchange the baterries that were used originally for a similar power supply.

Dhruv Kapur disse...

Thanks... Yes we will now be getting ourselves some laser safety gogg'z. Anyway how powerful was a laser pen? Cost? Were the beams visible enough? (in smoke)

Ruete disse...

Here are some tips to choose a good laser to use with this project:

1) Green lasers are more cheap than other colors and you can see them a lot better. For exemple if you shine a 100mW green laser and a 100mW red laser, the green one will appear to be a lot more brighter. So I choose a green one.

2) You must use some kind of fog to see it. This will depend on your budget. Here are a few options:
a) Fog machine (medium room to big room depending on the power of the machine).
b) Water Humidifier(will work only in a small room).
c) Turn your shower into hot position and wait... (will work on your bathroom ;) ) lol...

Those little 5mw green laser pointers will not work. Dont waist you money and time with them.

I used a 300mW green laser pen and a 1000mW green laser pen. Some people told me the label says it is rated 1000mW but it is not a REAL 1000mW laser.
I dont have a laser power meter so I cannot say if it outputs real 1000mW or not. But I can say it works. (You can see for yourself in the youtube video I posted in this blog. This one is the 1000mW used in a small room (my studio) with a water humidifier turned on.

Try to get at least a 100mW green laser pen. (and dont forget to buy and use the safety googles too).
If you can afford a more expensive one, go and buy it.
Most people use a 300mW certified module (modules are a little more expensive then a laser pen).
I used a pen because it was more cheap and easy to use. (you see I am not a master at electronics, and I guess laser modules would be a little harder for me to use.)

This was just a hobbie for me and but since I love Jean Michel Jarre music, I tryed until I eventualy succeed with it.

Hope this helps! Cheers!

Ruete disse...
Este comentário foi removido pelo autor.
Ruete disse...

About price: you should be able to find a 300mW green laser pointer for about US$40 here:

http://www.dhgate.com/wholesale/search.do?act=search&supplierid=&isfactory=&sus=&searchkey=300mw+green+laser&catalog=#search

or here:

http://www.alibaba.com/trade/search?SearchText=300mw+green+laser+pointer&CatId=0&IndexArea=product_en&isExportPage=Y&sq=y&fsb=y

P.S.: I am not afiliated with any of these vendors.

stein disse...

Hello,
I have two lasers (green and red)and i would like wen a note is playing, couple the lasers to have a powerfull ray. How i can make that?
Thanks a lot (and sorry for my english ^^')

Ruete disse...

I'm not sure I understand what you mean...
If you want to use two lasers at the same time, just adjust the second laser to shine at the same place the first laser is located. It will work as a dummy laser. It will shine at the same place, but the real trigger will be activated only by the first laser.
The secret is that midi notes are activated by a light sensor that detects "WHEN" the laser has been activated.
So if it detects laser light (reflection by the white gloves) WHEN the second beam is on for example it will send a midi D note (or any other note you setup)
It appears to the human eye that the harp laser is always on but in reality it shines one beam at a time.
This is how it works and how you can modify it.
I hope this helps.

stein disse...

Sorry for the bad english ^^'
I meant that I already realize the project but I try to couple the green laser with the red when the note is active...
- > when the exit 13 is active, to copy out the exit 7 towards another exit (for example 6) and to be able to control two lasers.
it's possible?

And thank you for the code and the description of the project, it is really great :)

Ruete disse...

sorry Stein... now you really got me confused...
please explain in more detail what you mean and I will try to help.

stein disse...


Okay ^^ '
Well, then I have at the moment a green laser for you for your project.
I would like to put a second laser who run when we play a note as this:

http://www.teferic.de/video/2/video/%20laser%20harpe/xp5lsq.html

But by coupling beam (first laser and the second laser togethers)

sorry again, I have difficulty in English and google translation do not help me a lot ^^'

Ruete disse...

Hi again Stein! They say a picture is worth a thousand words! Well in your case a video is worth a million words! :)
Now that I saw the video I think I understand what you want to do: you want to turn a red laser on when the note is played, right?
I think this is possible with a few modifications here.

First I need to explain how this laser harp works: when you reflect the laser light with a glove(play a note), the light sensor comunicates to the arduino that the laser is on, and the arduino plays a midi note until the light sensor tells it the laser reflection has stopped.
So if you use a red laser you will need to calibrate the light sensor so it continues to tell the arduino the laser is still on.(the reflection from the red laser will send a different amount of light then the green laser)


You will need to modify the following things:

1) Look at the picture below:

http://1.bp.blogspot.com/-8Rq-SQnTIFY/TzmbNry7BNI/AAAAAAAAABc/Z6ovdwS2c0c/s1600/ruete-laser-harp.jpg

I used arduino pin # 7 to turn the green laser on.
You must repeat the same thing using arduino pin # 6 and a red laser.

2) Insert a new code line inside arduino programing to turn the red laser on, when a note is played. TO do this substitute all lines like this:

"digitalWrite(13, HIGH);"

with this:

"digitalWrite(13, HIGH);
digitalWrite(LaserPin2, HIGH);"

3) Add a parameter definition for the red laser at the begining of the code change from this:

"const int LaserPin = 7; // define pin do arduino para o laser"

to this:

"const int LaserPin = 7; // define pin do arduino para o laser
const int LaserPin2 = 6; // red laser"

4) Use some mirrors to aim the red laser so it shines at the same place as the green laser!

5) Calibrate the light sensor changing the value of this line:

int sensor = 8 ; // valor do sensor calibrado

Good luck! Tell me if you have success!

Ruete disse...

One more thing:
Substitute all line with this:

"digitalWrite(13, LOW);"

for this

"digitalWrite(13, LOW); digitalWrite(LaserPin2, LOW);"

stein disse...

thank you a lot for the code :)
However, I wanted to run both at the same time laser when the note is played ( my red laser is less powerful than the green)-> red+green to have yellow color.
It will avoid having problem with the sensor.

français:/
merci pour le code :)
néanmoins, je voulais faire fonctionner les deux laser en même temps quand la note est jouée (mon laser rouge se voit beaucoup moins que le vert)
ça éviterai d'avoir des problèmes au niveau du capteur.
/

stein disse...

in fact I think the code is what I wanted to do, I try now!

I also doing a pcb circuit to simplify assembly but i make the second for the red laser now.
http://i34.servimg.com/u/f34/13/54/23/66/sdc10214.jpg

And my harp laser:
http://i34.servimg.com/u/f34/13/54/23/66/sdc10215.jpg

stein disse...

Hello!
That works but as my lasers are fed with inverse TTL (when there is +5v, the laser is switched off), the red laser makes the opposite of what I look for...
Can you help for that? thank you :)

Anônimo disse...

Hi,
Super project. I would request if you could give me figure out how to connect NEMA17 to ULN 2003. Google something helps but I'm not sure.
thank you
My e-mail dr.diodac@gmail.com

Ark

Ruete disse...
Este comentário foi removido pelo autor.
Ruete disse...

@Ark,

This will help you find out how to wire your motor:

http://www.youtube.com/watch?v=fTtwWJZlGt4&feature=player_embedded

http://www.easterngeek.com/2010/06/how-to-identify-stepper-motor-lead.html

Good luck,
Ruete.

Daniel Martins disse...

Olá, meu nome é Daniel e estou tentando projetar uma Harpa Laser do tipo frameless, porém estou tento alguns impasses... Quanto a projeção do laser após bater no espelho, seria correto aparecer "pontos" refletidos, mas o que está ocorrendo na verdade são pequenos traços, de mais ou menos 4cm. Peço urgentemente seu auxilio. Meu e-mail de contato é:
* daniell.cass@hotmail.com

FACEBOOK: facebook.com/danielmart01

Obrigado pela atenção e espero seu feedback o mais rápido possível.

Anônimo disse...

Oi, onde no código para alterar a velocidade do motor, porque eu tenho um problema tão grande. https://www.youtube.com/watch?v=017SS6g1q34

Ruete disse...

Para mudar a velocidade tente alterar estas duas linhas do código:

int delayligado = 5; //minimo 2 para aparecer direito o laser
int delaymexe = 3; //delay entre movimentos minimo 3

Mick disse...

É possível mudar o motor começou e onde ele mudou, porque eu tenho um motor que faz com que pequenos passos e vigas de ver, mas todo o feixe de laser é ao nível dos olhos 15 centímetros. Desculpe pelo meu Português, eu sou um Pólo.

Ruete disse...

Mick, não entendi direito o que você disse...
Fale em ingles então.
Mas vou tentar responder: É possível mudar onde o motor começa e termina(volta). E também quantos passos ele anda até parar e recomeçar.

Mick disse...

I have a motor that makes small steps, how to change the code to motor instead of with one step performed two or three steps?

Ruete disse...

MIck, If you want the motor to take two steps instead of one just delete this entire section:(and any other you want between where it says: "liga laser #" and "desliga laser #":


digitalWrite(LaserPin, HIGH); // liga laser 2
delay(delayligado);
//**********************************************************************************************************************************
if( (analogRead(0) >sensor ) && (buttonPresses == 0) ) //se o sensor esta ativado E ainda nao começou a tocar entao toca a nota++++++++++++

{
// faça A -----------------------------------------------------------------------------------------------------------
digitalWrite(13, HIGH); // acende o led
noteOn(0x90, note2, 0x7F); // toca a nota no: channel 1 = (0x90), nota = (note), volume = (0x7F)
buttonPresses++; // aumenta o valor do buttonPresses (para avisar que a nota ja comecou a tocar)
}

// --------------------------------------------------------------------------------------------------------------------
else if(analogRead(0) <sensor ) // e se o sensor esta desativado +++++++++++++++++++++++++++++++++++++++++++++++++++++++

{ // // faça B = silencia a nota
digitalWrite(13, LOW); // desliga o led
noteOn(0x90, note2, 0x00); // silencia a nota no: channel 1 (0x90), nota = (note), volume de silencio = (0x00)
buttonPresses = 0; // zera o "buttonPresses"
}
//**********************************************************************************************************************************
digitalWrite(LaserPin, LOW); // desliga laser 2
delay(delaydesligado);