Recent Posts

Pages: [1] 2 3 ... 10
1
Nederlands / Een hulpmiddel kan nuttig zijn...
Last post by Cecilla - Today at 12:29 pm
Een hulpmiddel kan nuttig zijn voor u.  EasyEDA is dat ontwerpers toegang hebben tot Open Source modulen ontwikkeld door duizenden elektronische ontwerpers. https://easyeda.com/nl

EasyEDA is een gratis, installatie-vrije, EDA gereedschap op basis van Cloud-technologie, het is ontworpen om elektronica ontwerpers, docenten, technische studenten en elektronica hobbyisten een eenvoudigere EDA ervaring te geven, de ervaring van het automatiseren van het elektronische ontwerp. Het is eenvoudig in het gebruik voor het ontwerp en simuleren van schakelingen en printplaat (PCB) ontwerp en het draait in je web browser.

2
Deutsch / Re: Rotary Encoder am Midi con...
Last post by SkobyMobil - Today at 12:28 pm
Hallo,
ich hatte auch erst gedacht, noch einmal darauf einzugehen- lasse es aber.
Ich nutze für Musik meinen CD-Player- ganz ohne Arduino.  ;)
Gruß und Spaß
Andreas
3
I changed the code;

Code: [Select]
#include <Wire.h>
#define SLAVE_ADDRESS 0x0B
 volatile byte command=0x00;

void setup() {
Wire.begin(SLAVE_ADDRESS);
Wire.onReceive(receiveData);
Wire.onRequest(sendData);}

void loop() {}

void receiveData(volatile int byteCount){
 command=Wire.read();
 while (Wire.available()>0){
 Wire.read();}
}

void sendData(){ 
    Wire.write(command);
    command=0;
    Wire.write(command);
}

Now I send 2 Bytes to the master and the master receives the command I want, but NO WHEN I WANT. This is what happends:

Master to Slave command:       Slaves read command:     Value sent to Master:
         A                                                        10  (in HEX, A)                       0
         D                                                        13  (in HEX, D)                    000A
         E                                                        14  (in HEX, E)                     000D
         3                                                         3                                       000E

It seems that the program enters to "receivedata" when the master sends a command. But after having received the command from the master, is not entering to "sendData", when it should.

Any idea to solve this?? Thank you in advance.
4
Programming Questions / Trying to create a header for ...
Last post by ao90 - Today at 12:26 pm
I am trying to create a header for my CSV file before I start logging data. My data logs later when I want it to but when I attempt to open the file here and set the header it does not work. Can anyone see my mistake?



Code: [Select]

void setup() {
      pinMode(programpin, OUTPUT);
      Wire.begin();
      lcd.begin(16, 2);                   // initiate LCD                               
                                          // initialize serial communication at 9600 bits per second
      Serial.begin(9600);                 // baud rate for computer serial communication
while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.print("Initializing SD card...");
  pinMode(chipSelect, OUTPUT);
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
     
  if (dataFile) {
  File dataFile = SD.open(filename); 
  dataFile.println("Event,Time,Date");
  dataFile.close();
 }
  else
  {
    Serial.println("Couldn't open log file");
    return;
  }
  RTC.begin();
  if (! RTC.isrunning()) {
    lcd.print("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // uncomment it & upload to set the time, date and start run the RTC!
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  clearPrintTitle();
}
5
Hi All, just want to advise this post is no longer needed - we have found a code developer to assist with our project.

Thanks
6
Bar Sport / Re: I'm sick, can i stay home?
Last post by travis_farmer - Today at 12:24 pm
this steam locomotive is in my area.
http://www.dailybulldog.com/db/features/narrow-gauge-steam-engine-returns-to-phillips/

IIRC, I think it is a 0-4-4.

~Travis
7
Software / Re: gestione eventi
Last post by peterbod - Today at 12:23 pm
Buongiorno a tutti, mi sto avvicinando ora al mondo Arduino per la realizzazione di alcuni, semplici, progetti modellistici.
Avendo la necessità di riprodurre casualmente dei file .mp3, ho scritto uno sketch il quale per ogni pressione su un tasto, ne riproduce uno, a caso da un gruppo di 16. Funziona.
L'appetito vien mangiando e quindi ho pensato che abbinare un movimento casuale di un servo alla riproduzione degli mp3 potesse rendere più "vivo" il progetto. Quindi usando lo stesso sketch con le opportune modifiche, riesco a far fare rotazioni di 16 angoli diversi, a caso, al braccio del servo. Quello che non riesco a fare sono le due cose insieme; ossia riprodurre un mp3 a caso e far eseguire un movimento casuale al servo. Viene sempre e solo riprodotto un file mp3. Di seguito lo sketch dove sono attivi i comandi per gli mp3 e disattivati quelli per i movimenti del servo:

#include <Servo.h>
#include <SdFat.h>
#include <MP3Player.h>
Servo myservo;               // creo l'oggetto myservo

int grado = 85;                // variabile per la posizione iniziale del servo
int pinServo = 9;              // variabile per il pin di collegamento del servo
int RS;                           // variabile random per servo
int RA;                           // variabile random per mp3
int tasto = 6;                  // variabile per il pin di collegamento del tasto

void setup() {
  pinMode (tasto, INPUT_PULLUP); 
  randomSeed(analogRead(A0));       //generazione di un valore random in base allo stato di A0 non in uso

  RS = random(1, 17);                    // valori random da 1 a 16
  RA = random(1, 17);                    // valori random da 1 a 16
 
  mp3.Init(3, 2);                            // inizializzazione sceda mp3 (MP3Shield della Cytron)
  myservo.attach( pinServo );          // servo collegato al pin della variabile pinServo (9)
  myservo.write( grado );                // posizione iniziale del servo in base alla variabile grado (85)

 }

void loop()
{
 
  RS = random(1, 17);
  RA = random(1, 17);
  int val = digitalRead (tasto);        // variabile che registra lo stato del tasto
 
  if (val == LOW && RA == 1)  { mp3.PlayTrack("1.mp3");     delay(1000);  }
//if (val == LOW && RS == 1){myservo.write(0) ;delay(500);}
  if (val == LOW && RA == 2)  { mp3.PlayTrack("2.mp3");     delay(1000);  }
//if (val == LOW && RS == 2){myservo.write(85) ;delay(500);}
  if (val == LOW && RA == 3)  { mp3.PlayTrack("3.mp3");     delay(1000);  }
//if (val == LOW && RS == 3){myservo.write(170) ;delay(500);}
  if (val == LOW && RA == 4)  { mp3.PlayTrack("4.mp3");     delay(1000);  }
//if (val == LOW && RS == 4){myservo.write(0) ;delay(500);}
  if (val == LOW && RA == 5)  { mp3.PlayTrack("5.mp3");    delay(1000);  }
//if (val == LOW && RS == 5){myservo.write(85) ;delay(500);}
  if (val == LOW && RA == 6)  { mp3.PlayTrack("6.mp3");    delay(1000);  }
//if (val == LOW && RS == 6){myservo.write(170) ;delay(500);}
  if (val == LOW && RA == 7)  { mp3.PlayTrack("7.mp3");    delay(1000);  }
//if (val == LOW && RS == 7){myservo.write(0) ;delay(500);}
  if (val == LOW && RA == 8)  { mp3.PlayTrack("8.mp3");    delay(1000);  }
//if (val == LOW && RS == 8){myservo.write(85) ;delay(500);}
  if (val == LOW && RA == 9)  { mp3.PlayTrack("9.mp3");    delay(1000);  }
//if (val == LOW && RS == 9){myservo.write(170) ;delay(500);}
  if (val == LOW && RA == 10)  { mp3.PlayTrack("10.mp3");    delay(1000);  }
//if (val == LOW && RS == 10){myservo.write(0) ;delay(500);}
  if (val == LOW && RA == 11)  { mp3.PlayTrack("11.mp3");    delay(1000);  }
//if (val == LOW && RS == 11){myservo.write(85) ;delay(500);}
  if (val == LOW && RA == 12)  { mp3.PlayTrack("12.mp3");    delay(1000);  }
//if (val == LOW && RS == 12){myservo.write(170) ;delay(500);}
  if (val == LOW && RA == 13)  { mp3.PlayTrack("13.mp3");    delay(1000);  }
//if (val == LOW && RS == 13){myservo.write(0) ;delay(500);}
  if (val == LOW && RA == 14)  { mp3.PlayTrack("14.mp3");    delay(1000);  }
//if (val == LOW && RS == 14){myservo.write(85) ;delay(500);}
  if (val == LOW && RA == 15)  { mp3.PlayTrack("15.mp3");     delay(1000);  }
//if (val == LOW && RS == 15){myservo.write(170) ;delay(500);}
  if (val == LOW && RA == 16)  { mp3.PlayTrack("16.mp3");     delay(1000);  }
//if (val == LOW && RS == 16){myservo.write(0) ;delay(500);}
//myservo.write( 85) ;
 }


Ciò che ho provato, ma non funziona, nel senso che viene solo riprodotto il file, è stata la seguente stringa:

 if (val == LOW && RA == 1){ mp3.PlayTrack("X.mp3");delay(500);myservo.write(Y);delay(1000);}

dove X è il nome del file e Y l'angolo del braccio del servo diversi per ogni stringa.

Qualche dritta?
8


const int trigPin = 5;


const int echoPin = 6;
int motorPin1 = 3; // pin 2 on L293D IC
int motorPin2 = 4; // pin 7 on L293D IC
int enablePin = 7;
void setup() {

// initialize serial communication:

Serial.begin(9600);
pinMode(motorPin1, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(enablePin, OUTPUT); // attaches the servo on pin 9 to the servo object
digitalWrite(enablePin, HIGH);
// attaches the servo on pin 9 to the servo object
pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);




}

void loop() {
 
// and the distance result in centimeters:

long duration, cm;

pinMode(trigPin, OUTPUT);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(20);

digitalWrite(trigPin, LOW);

pinMode(echoPin, INPUT);

duration = pulseIn(echoPin, HIGH);

// convert the time into a distance

cm = microsecondsToCentimeters(duration);

// the condition for the distance

if ( cm > 1 && cm < 24)

{

 digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
       digitalWrite(motorPin2,HIGH ); // sets the servo position according to the scaled value

delay(1000);

}


else

{

digitalWrite(motorPin1, HIGH); // set pin 2 on L293D high
       digitalWrite(motorPin2, LOW);  // sets the servo position according to the scaled value

delay(1000);

}

Serial.print(cm);

Serial.print("cm");

Serial.println();

delay(100);

}

long microsecondsToCentimeters(long microseconds) {

// The speed of sound is 340 m/s or 29 microseconds per centimeter.

// The ping travels out and back, so to find the distance of the

// object we take half of the distance travelled.

return microseconds / 29 / 2;

}

this code has 2 coditions
i want edit in code ,to make motor move in one direction when i put something in front module for 2 sec and stop ,,,and in other direction when i remove this thing for 2 sec then stop ! ?
9
General Electronics / Re: Dual power supplies (5V an...
Last post by MarkT - Today at 12:20 pm
The Arduino pins are rated up to a abs max of 40mA source or sink, the LS04 is rated for 8mA sink
and 0.4mA source, so rather than buffering the Arduino pin you've reduced the drive power drastically.
Consider a 7406 open collector buffer, more current sinking capability and open-collector means you
don't have to use remote power for it.

You also should ideally tie unused inputs of any TTL chip to ground (or to Vcc with 1k resistor)

You should not add any series resistance to the power of a logic chip, and you must use decoupling
cap(s).
10
Deutsch / Re: Rotary Encoder am Midi con...
Last post by Doc_Arduino - Today at 12:18 pm
Hallo,

womit will er dann seinem Programm sagen das er was auslesen bzw. ändern möchte?
Ehrlich gesagt blicke ich nicht durch was er wirklich wie machen möchte.
Ich dachte er möchte hintereinander alle Werte einzeln ändern.



Pages: [1] 2 3 ... 10

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy