Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
2
|
Using Arduino / Project Guidance / Audio input to control pnematic relays.
|
on: September 08, 2012, 11:54:25 am
|
|
Halloween is a coming and i am working on updating some animatronics. They run on cassette tapes at the moment and the boars are marked '87 so thought id update them.
I wish to run an arduino with either a SMD card on it with the audio files on there, and output the audio files. The audio files will just be voice and the audio signal will go into the arduino which then out puts 5 volt signals to some transistors to gate to switch the 24V to the pneumatic relays to activate.
Should i use the wave shield to accomplish this? or a simpler way you think? Possibly split the audio to the speakers and to the arduino input. using voltage references to trigger output to the transistor switches.
Any help would be great
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Re: Arduino Mega, freezezs when connecting to server
|
on: August 24, 2011, 01:44:57 pm
|
sorry for the delay, Here is how i am sending the emails with attachments. The code it actually in is alot bigger but the email sending is the same principal. #include <Ethernet.h> #include <SPI.h> #include <SD.h>
char Sfile[]= {"S00DATA.csv"};
char filetype[] = {"csv"}; byte slave_address = 2; byte SLAVE_END = 3;
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x6D, 0xD6 }; // Arduino's artificial mac address byte ip[] = { 0, 0, 0, 0 }; // my ip byte server[] = { 0, 0, 0, 0 }; // my smtp server ip int time = 5000; int wait = 2000;
File datatxt; Client client(server, 25);
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const int chipSelect = 4;
char Sender_email[] ={"blah@gmx.com"};
void setup() { delay(time); Ethernet.begin(mac, ip); Serial.begin(9600); delay(1000); pinMode(10,OUTPUT);
Serial.print("Initializing SD card..."); if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized.");
}
void loop() { Serial.println("connecting..."); if (client.connect()) { Serial.println("connected"); client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/ delay(wait); /* wait for a response */
client.println("MAIL From: blah@gmx.com"); /* identify sender, this should be the same as the smtp server you are using */ delay(wait); /* wait for a response */
client.println("RCPT To:blahe@virelec.com"); /* identify recipient */ delay(wait); /* wait for a response */
client.println("DATA"); delay(wait); /* wait for a response */ client.println("Subject: text file attached"); client.print("Content-type: multipart/mixed; boundary=\"$boundary\" \r\n"); while(slave_address <= SLAVE_END){ add_attachment(slave_address); slave_address++; } client.println("."); /* end email */ client.println("QUIT"); /* terminate connection */ delay(wait); /* wait for a response */ } else { Serial.println("connection failed"); } while (client.available()) { char c = client.read(); Serial.print(c); } if (!client.connected()) { Serial.println(); Serial.println("disconnecting."); client.stop(); slave_address = 0; delay(300000); } }
void encodeblock(unsigned char in[3],unsigned char out[4],int len) { out[0]=cb64[in[0]>>2]; out[1]=cb64[((in[0]&0x03)<<4)|((in[1]&0xF0)>>4)]; out[2]=(unsigned char) (len>1 ? cb64[((in[1]&0x0F)<<2)|((in[2]&0xC0)>>6)] : '='); out[3]=(unsigned char) (len>2 ? cb64[in[2]&0x3F] : '='); }
void encode() { unsigned char in[3],out[4]; int i,len,blocksout=0; while (datatxt.available()!=0) { len=0; for (i=0;i<3;i++){ in[i]=(unsigned char) datatxt.read(); if (datatxt.available()!=0) len++; else in[i]=0; } if (len){ encodeblock(in,out,len); for(i=0;i<4;i++) client.write(out[i]); blocksout++; } if (blocksout>=19||datatxt.available()==0){ if (blocksout) client.print("\r\n"); blocksout=0; } } }
void add_attachment(byte slave){ client.print("--$boundary\r\n"); Sfile[1] =(slave/10 + 48); Sfile[2] =(slave%10 + 48); datatxt =SD.open(Sfile,FILE_READ); client.print("Content-Type: "); client.print(filetype); client.print("; "); client.print("name="); client.println(Sfile); client.print("Content-Disposition: attachment; "); client.print("filename="); client.println(Sfile); client.println("Content-Transfer-Encoding: base64"); client.println(""); encode(); datatxt.close(); delay(wait); }
it sends an email a few times then halfway through it seems to be cutting out and starting again. SERIAL MONITOR: disconnecting. connecting... connected 220 to5email2.gprs.rogers.com ESMTP server (InterMail vM.7.09.00.04 201-2219-102-106-20090410) ready Wed, 24 Aug 2011 14:33:47 -0400 250 to5email2.gprs.rogers.com 250 Sender <blah@gmx.com> Ok 250 Recipient <bla@virelec.com> Ok 354 Ok Send data ending with <CRLF>.<CRLF> 250 Message received: 20110824183353.IFDQ13635.to5email2.gprs.rogers.com@itismeletschat 221 to5email2.gprs.rogers.com ESMTP server closing connection
disconnecting. connecting... connected 220 to5email2.gprs.rogers.com ESMTP server (InterMail vM.7.09.00.04 201-2219-102-106-20090410) ready Wed, 24 Aug 2011 14:39:00 -0400 250 to5email2.gprs.rogers.com 250 Sender <blao@gmx.com> Ok 250 Recipient <bla@virelec.com> Ok 354 Ok Send data ending with <CRLF>.<CRLF> connecting... connection failed connecting... connection failed connecting... connection failed
|
|
|
|
|
5
|
Using Arduino / Programming Questions / enough space?
|
on: August 22, 2011, 03:59:15 pm
|
|
Binary sketch size: 22274 bytes (of a 32256 byte maximum)
my program seems to not run with this memory used in sketch.
would this be the problem?
I can run other sketches on the same arduino with less mem used
|
|
|
|
|
7
|
Using Arduino / Programming Questions / SOLVED:User input turned to HEX
|
on: August 22, 2011, 12:35:07 pm
|
|
Idea:
User inputs in serial monitor "A3" when read in hex it will be 0x41 and 0x33
I would like when read in HEX it will be 0xA3
how can i achieve this?
i know how to read the values and such and I'm reading one value at a time, so "A" then the "3"
|
|
|
|
|
9
|
Using Arduino / Programming Questions / SOLVED:Checking variable for while loop, updated from Interrupt
|
on: August 18, 2011, 11:44:55 am
|
I am using a TIMER1 overflow interrupt, I have written a quick code to test to see if i can update a variable with the interrupt as its being checked by a while statement. #include "TimerOne.h" byte FLAG = 0; void setup() { Serial.begin(9600); pinMode(6, OUTPUT); Timer1.initialize(1000000); Timer1.attachInterrupt(callback); Timer1.stop(); } void callback() { digitalWrite(6, HIGH); delay(10); digitalWrite(6, LOW); FLAG = 1; Timer1.stop(); } void loop() { Serial.println("SEND MESSAGE"); Timer1.start(); Serial.println("RECEIVING"); while(FLAG == 0); FLAG = 0; delay(10000); }
It doesn't notice the interrupt change in the FLAG status with : while(FLAG == 0); It does notice the flag change however if i put something in the while loop to check eg: while(FLAG ==0){ Serial.println(FLAG, DEC); } Does anyone know why this is happening? Doesn't " while(FLAG == 0);" continuously check the state of FLAG anyways?
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client
|
on: August 15, 2011, 02:53:32 pm
|
okay i figured that out too, here's a post Incase someone is wondering. Sending Multiple Attachments Serial.println("connected"); client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/ delay(wait); /* wait for a response */
client.println("MAIL From: blank@gmx.com"); /* identify sender, this should be the same as the smtp server you are using */ delay(wait); /* wait for a response */
client.println("RCPT To: blank@virelec.com"); /* identify recipient */ delay(wait); /* wait for a response */
client.println("DATA"); delay(wait); /* wait for a response */ client.println("Subject: text file attached"); [b]client.print("Content-type: multipart/mixed; boundary=\"$boundary\" \r\n");[/b] [b]client.print("--$boundary\r\n");[/b] datatxt =SD.open("HEAD2.csv",FILE_READ); client.print("Content-Type: csv; name=\"HEAD2.csv\"\r\nContent-Disposition: attachment; filename=\"HEAD2.csv\"\r\nContent-Transfer-Encoding: base64\r\n\r\n"); encode(); datatxt.close(); delay(wait); datatxt =SD.open("meow.txt",FILE_READ); [b]client.print("--$boundary\r\n");[/b] client.print("Content-Type: txt; name=\"meow.txt\"\r\nContent-Disposition: attachment; filename=\"meow.txt\"\r\nContent-Transfer-Encoding: base64\r\n\r\n"); encode(); datatxt.close(); client.println("."); /* end email */ client.println("QUIT"); /* terminate connection */ delay(wait); /* wait for a response */
|
|
|
|
|
14
|
Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client
|
on: August 15, 2011, 10:17:54 am
|
This is the code i am running with the headers after data, which sends an email but no attachment just places those lines of code in the email body. the results i posted above is when the "DATA" line is removed and the subject #include <Ethernet.h> #include <SPI.h> #include <SD.h>
byte mac[] = { 0, 0, 0, 0, 0, 0 }; // Arduino's artificial mac address byte ip[] = { 0, 0, 0, 0 }; // my ip byte server[] = { 0, 0, 0, 0 }; // my smtp server ip int time = 5000; int wait = 2000;
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
File datatxt; Client client(server, 25);
void setup() { delay(time); Ethernet.begin(mac, ip); Serial.begin(9600); delay(1000); pinMode(10,OUTPUT); SD.begin(4); Serial.println("connecting..."); if (client.connect()) { Serial.println("connected"); client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/ delay(wait); /* wait for a response */
client.println("MAIL From: camarduino@gmx.com"); /* identify sender, this should be the same as the smtp server you are using */ delay(wait); /* wait for a response */
client.println("RCPT To: cameroncollie@gmail.com"); /* identify recipient */ delay(wait); /* wait for a response */
client.println("DATA"); delay(wait); /* wait for a response */ datatxt =SD.open("data.txt",FILE_READ); client.println("Subject: Picture attached"); client.print("Content-Type: txt; name=\"data.txt\"\r\nContent-Disposition: attachment; filename=\"data.txt\"\r\nContent-Transfer-Encoding: base64\r\n\r\n"); client.println("."); /* end email */ client.println("QUIT"); /* terminate connection */ delay(wait); /* wait for a response */ client.stop(); datatxt.close(); } else { Serial.println("connection failed"); } }
void loop() { while (client.available()) { char c = client.read(); Serial.print(c); } if (!client.connected()) { Serial.println(); Serial.println("disconnecting."); client.stop(); for(;;) ; } }
void encodeblock(unsigned char in[3],unsigned char out[4],int len) { out[0]=cb64[in[0]>>2]; out[1]=cb64[((in[0]&0x03)<<4)|((in[1]&0xF0)>>4)]; out[2]=(unsigned char) (len>1 ? cb64[((in[1]&0x0F)<<2)|((in[2]&0xC0)>>6)] : '='); out[3]=(unsigned char) (len>2 ? cb64[in[2]&0x3F] : '='); }
void encode() { unsigned char in[3],out[4]; int i,len,blocksout=0; while (datatxt.available()!=0) { len=0; for (i=0;i<3;i++){ in[i]=(unsigned char) datatxt.read(); if (datatxt.available()!=0) len++; else in[i]=0; } if (len){ encodeblock(in,out,len); for(i=0;i<4;i++) client.write(out[i]); blocksout++; } if (blocksout>=19||datatxt.available()==0){ if (blocksout) client.print("\r\n"); blocksout=0; } } }
|
|
|
|
|
15
|
Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client
|
on: August 12, 2011, 12:35:43 pm
|
can you use the code above that razor blade posted above for txt files? i placed the code with .txt instead of jpgs but when i run it i get this connected 220 to5email2.gprs.rogers.com ESMTP server (InterMail vM.7.09.00.04 201-2219-102-106-20090410) ready Fri, 12 Aug 2011 13:28:53 -0400 250 to5email2.gprs.rogers.com 250 Sender < camarduino@gmx.com> Ok 250 Recipient < cam_the_man007@hotmail.com> Ok 500 Command unknown: 'CONTENT-TYPE:;' 500 Command unknown: 'CONTENT-DISPOSITION:' 500 Command unknown: 'CONTENT-TRANSFER-ENCODING:' 500 Command unknown: '' 500 Command unknown: 'BWVVDYBTZW93IG1LBW==' 500 Command unknown: '.' 221 to5email2.gprs.rogers.com ESMTP server closing connection any insight?
|
|
|
|
|