Varsinaisesta viasta en osaa sanoa muuta kuin äkkiseltään näytti ainakin yksi aaltosulku olevan väärin päin, tosin tuostakaan en varmaksi mene vannomaan, kun ei tuosta koodista selvää saanut edellämainitun ongelman vuoksi
Kipe kirjoitti:Aivan ensimmäiseksi: opettele käyttämään sisennyksiä koodatessa, aivan kaameaa lukea tuo nykyine :S
Varsinaisesta viasta en osaa sanoa muuta kuin äkkiseltään näytti ainakin yksi aaltosulku olevan väärin päin, tosin tuostakaan en varmaksi mene vannomaan, kun ei tuosta koodista selvää saanut edellämainitun ongelman vuoksi
#include <IRremote.h>
int motor1 = 2; //declares the first pin for the motor
int motor2 = 4; //declares the other pin for the motor
int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed)
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(motor1, OUTPUT); //
pinMode(motor2, OUTPUT); // these simply are declaring them as outputs
pinMode(motorpmw, OUTPUT); //
pinMode(13, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (irrecv.decode(&results)){
}
if(results.value == 0xFD30CF)//
{
digitalWrite(13,LOW);
delay (1000);//
}
else if(results.value == 0xFD00FF)
{
digitalWrite(13,HIGH);
tone(6, 340, 200);
}
else if(results.value == 0xFD20DF)
{
analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255)
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW); //turns the motors on - forwards
}
}
}
{
irrecv.resume(); // Receive the next value
}
#include <IRremote.h>
int motor1 = 2; //declares the first pin for the motor
int motor2 = 4; //declares the other pin for the motor
int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed)
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(motor1, OUTPUT); //
pinMode(motor2, OUTPUT); // these simply are declaring them as outputs
pinMode(motorpmw, OUTPUT); //
pinMode(13, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
}
if (irrecv.decode(&results))
{
}
if(results.value == 0xFD30CF)//
{
digitalWrite(13,LOW);
delay (1000);//
}
else if(results.value == 0xFD00FF)
{
digitalWrite(13,HIGH);
tone(6, 340, 200);
}
else if(results.value == 0xFD20DF)
{
analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255)
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW); //turns the motors on - forwards
}
irrecv.resume(); // Receive the next value
}zire87 kirjoitti:
- Koodi: Valitse kaikki
#include <IRremote.h>
int motor1 = 2; //declares the first pin for the motor
int motor2 = 4; //declares the other pin for the motor
int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed)
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(motor1, OUTPUT); //
pinMode(motor2, OUTPUT); // these simply are declaring them as outputs
pinMode(motorpmw, OUTPUT); //
pinMode(13, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
}
if (irrecv.decode(&results))
{
}
if(results.value == 0xFD30CF)//
{
digitalWrite(13,LOW);
delay (1000);//
}
else if(results.value == 0xFD00FF)
{
digitalWrite(13,HIGH);
tone(6, 340, 200);
}
else if(results.value == 0xFD20DF)
{
analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255)
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW); //turns the motors on - forwards
}
irrecv.resume(); // Receive the next value
}
Lisäsin sisennykset tohon aikaisempaan koodiisi, jolloin siitä tuli huomattavasti helpommin luettava. Samalla poistin muutaman ylimääräisen kaarisulun koodin lopusta.
Tosiaan kannattaa opetella käyttämään noita sisennyksiä. Se helpottaa huomattavasti esim. puuttuvien kaarisulkujen ja muiden virheiden havaitsemista.
#include <IRremote.h>
int motor1 = 2; //declares the first pin for the motor
int motor2 = 4; //declares the other pin for the motor
int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed)
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(motor1, OUTPUT); //
pinMode(motor2, OUTPUT); // these simply are declaring them as outputs
pinMode(motorpmw, OUTPUT); //
pinMode(13, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
{
}
if (irrecv.decode(&results))
{
}
if(results.value == 0xFFC03F)//
{
digitalWrite(13,HIGH);
delay (1000);//
}
else if(results.value == 0xFF807F)
{
digitalWrite(13,LOW);
}
else if(results.value == 0xFD20DF)
{
analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255)
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW); //turns the motors on - forwards
}
irrecv.resume(); // Receive the next value
}
}
uk350 kirjoitti:ööh, ledi? voiskos sen tiputtaa pois? 9 releelle + 1 ir:lle jää vielä puolet pinneistä vapaaksi ja jos musashieldistä riittää play/stop niin eikös siinä just riitä pinnit, siinähän tais olla 4 käyttämätöntä ja 8 joita voi käyttää muihin sovelluksiin joista kuitenkin 1 on tuo play eli 11 jäis vapaaksi? mahtuu vielä se ledikin mukaan.
D0 - Unused.
D1 - Unused.
D2 - Used for receiving signal from iPod dock(could be used for your own application if iPod dock is not used).
D3 - Used for receiving signal from button for Volume Up(could be used for your own application if the switch is not used).
D4 - Used for receiving signal from switch for Next Song function(could be used for your own application if the switch is not used).
D5 - Used for receive signal from switch for Play&Stop and Record function(could be used for your own application if the switch is not used).
D6 - Used for receive signal from switch for Previous Song function(could be used for your own application if the switch is not used).
D7 - Used for receiving signal from button for Volume Down(could be used for your own application if the switch is not used).
D8 - Used for Green Led instructions(could be used for your own application if the switch is not used).
D9 - Used for Red Led instructions(could be used for your own application if the switch is not used).
D10 - Used for SPI Chip Select.
D11 - Used for SPI MOSI.
D12 - Used for SPI MISO.
D13 - Used for SPI SCK.
D14(A0) - Used for Reset of VS1053.
D15(A1) - Used for Data Require of VS1053.
D16(A2) - Used for Data Select of VS1053.
D17(A3) - Used for Chip Select of VS1053.
D18(A4) - Unused.
D19(A5) - Unused.
Limba kirjoitti:Jos alkaa loppumaan nuo IO:t niin tuossa olis tollasta korttiakin olemassa (Beaglebone).
http://tigal.fi/product/2361
Tuossa ainakin vähäksi aikaa pitäisi olla IO:ta saatavilla. Tuosta versiosta tais olla audio lähdöt jätetty pois.
Toisena asiana ratkaisuna ja ehkä helpompana voisi olla esim. I2C IO expanderilla lisää IO pinnejä arduinoon, mutta vaatii sitten lisäsoftaa. Tämä ratkaisu kuitnekin on helpompi kuin alkaa tekeen tuota samaa linuxin päälle.
Kannattaa pitää mielessä sitten se 32kB flash rajoitus, jos meinaa enemmän älyä siihen alkaa tekeen
Play music:
Make sure there are songs in the micro sd card.
Download File:Music v1 14.zip and File:NewSoftSerial.zip for music shield.
Uncompress these two packages and put them in Arduino-0022 program: ..\arduino-0022\libraries
Download a new portpins.h file and replace the default portpins.h file of Arduino-0022 program: ..\arduino-0022\hardware\tools\avr\avr\include\avr
Select the corresponding Arduino board, like Arduino UNO or Duemilanove or others.
Run the arduino program compile and download the sketch of music_v1_14 -> music into Arduino board.
Just enjoy.
Käyttäjiä lukemassa tätä aluetta: Bing [Bot] ja 0 vierailijaa