Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Parsing a string. on: July 10, 2013, 04:05:25 am
Guys, I want to parse data sent through the serial connection:

Here's the example sting:

$GPRMC,082354.000,A,1324.9294,N,12135.8584,E,0.0,344.9,100713,,,A*6B

It spits out other data with a different starting header, and I only want the $GPRMC data to be read, and sent to me. plus, I only want these data points:


1324.9294
12135.8584

Another problem is, is that the data should be expressed like this:

13 24.9294 & 121 35.8584

how do I get about this dilemma?

Thanks guys!

2  Using Arduino / Programming Questions / Re: Comparing 3 values. on: July 10, 2013, 03:56:17 am
Thanks for the input guys! smiley
3  Using Arduino / Programming Questions / Re: Comparing 3 values. on: June 24, 2013, 05:27:00 pm
thanks for your replies!

im a bit confused. the "max" command worked, but how could i return the variable with the largest value? for example:

x = 1;
y = 3;
z = 4;

since z is the greatest reading, then it would do a certain action.
4  Using Arduino / Programming Questions / Comparing 3 values. on: June 24, 2013, 06:37:56 am
Guys, let's say i want to compare 3 values, from measurements, X, Y and Z. And I want to get the largest value of the 3 variables. How do I approach this problem with the arduino to do an action when the greatest value is read?

Thanks in advance for your replies. smiley-grin
5  Using Arduino / Programming Questions / Re: 2 "void loop"s? on: June 11, 2013, 07:31:25 pm
Hmmm... Thanks for your replies! I was planning something like this:

Code:

void setup() {

int x = 0;
int a = 0;
int b = 0;
int y = 0;
}


void loop() {
  if (x == 1) {
    nextchunkofcode(); //call next loop}

  //main code here

if y == some value obtained from nextchunkofcode() //use from nextchunkofcode()


  }
}

void nextchunkofcode() {
//another chunk of code
  a = 1;
  b = 2;

y = analogRead(pin);

}

Would this possibly work?
6  Using Arduino / Programming Questions / 2 "void loop"s? on: June 11, 2013, 07:14:02 pm
Is it possible to have 2 loops that can be chosen to run in an arduino code?

for example:

Code:

void loop()

{ if x == 1
{ nextchunkofcode() //call next loop}

//main code here}

void nextchunkofcode()
{
//another chunk of code

a = 1;
b = 2;

}


Also, will the values that you obtained in the nextchunkofcode loop be saved in the main RAM and can be used in the main loop loop?
7  Using Arduino / Networking, Protocols, and Devices / GSM shield help on: March 05, 2013, 09:16:16 pm
Im currently trying to create a device that would alert me when a certain limit is reahced, and it would alert me via GSM.


I modified the sample code, and it works great, although, I noticed one problem, when I run it as a standalone system, it does not work, but when i plug it into the computer, it works, WHEN the serial monitor is started. How do i overcome this?

here's the code.

Code:
/*
  GSM Send Sketch for Arduino
 
  Initializes GSM Module and sends an SMS to recipient
 
  The circuit:
  *Arduino pin 0 (RX) - GSM Module (TX)
  *Arduino pin 1 (TX) - GSM Module (RX)
 
  Created 2010
  by Meann Zabanal
  Modified
  by John for GSM Shield testing
*/

char Rx_data[50];
unsigned char Rx_index = 0;
int i = 0;
char msg[160];
int sig;

void setup() {
 
  Serial.begin(38400);
 
  initGSM();
  send_msg("09276191847", "Hello");
}

void loop() {
 

}

void send_msg(char *number, char *msg)
{
 
  int val = 1;
 
  if (val==1){
  char at_cmgs_cmd[30] = {'\0'};
  char msg1[160] = {'\0'};
  char ctl_z = 0x1A;

  sprintf(msg1, "%s%c", msg, ctl_z);
  sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number);
 
  sendGSM(at_cmgs_cmd);
  delay(100);
  delay(100);
  delay(100);
  sendGSM(msg1);
  delay(100);
  send_msg("09******47", "Hello");
  }
 
  if (val == 0);
  {
    Serial.println("The value is Zero");
    send_msg("09276191847", "Hello");
  }

}

void sendGSM(char *string){
  Serial.write(string);
  delay(90);
}

void clearString(char *strArray) {
  int j;
  for (j = 100; j > 0; j--)
    strArray[j] = 0x00;
}

void send_cmd(char *at_cmd, char clr){
  char *stat = '\0';
  while(!stat){
    sendGSM(at_cmd);
    delay(90);
    readSerialString(Rx_data);
   
    stat = strstr(Rx_data, "OK");
  }
  if (clr){
    clearString(Rx_data);
    delay(200);
    stat = '\0';
  }
}

void initGSM(){
  send_cmd("AT\r\n",1);
//  send_cmd("ATE0\r\n",1); // Turn off automatic echo of the GSM Module

  send_cmd("AT+CMGF=1\r\n",1); // Set message format to text mode
  //Sucess
 
  Serial.println("Success");

  delay(1000);
  delay(1000);
  delay(1000);
 
}

void readSerialString (char *strArray) {
 
  if(!Serial.available()) {
    return;
  }
 
  while(Serial.available()) {
    strArray[i] = Serial.read();
    i++;
  }
}

8  Using Arduino / Project Guidance / Re: DS1307 as an alarm. on: February 06, 2013, 05:34:06 pm
Hey olof_n!

Thanks for the reply and help!

I was looking at the code, where you have to store it in either the EEPROM or RAM of the DS1307, considering that I have multiple times that require an alarm, what would be the best way to approach this?

Looking at the code, please do guide me, since I'm still a newbie in programming. i out some comments on each line where I get confused.

Code:
void set_alarm(byte ah,byte am)
{
  write_byte(1, ah);         //ah is the hour?
  write_byte(2, am);        //am is the minute?
}
void get_alarm()
{
  bAlarmHours=read_byte(1);        //So this part reads the data from the EEPROM?
  bAlarmMinutes=read_byte(2);
}

//Is this a new code? like as you said in your statement above, I can either use the EEPROM, or the DS1307 RAM.

byte read_byte(byte bAdress)
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS); 
  Wire.write(0x08+bAdress);                   // Set the register pointer to (0x08) to read first memory byte
  Wire.endTransmission();                     
  Wire.requestFrom(DS1307_I2C_ADDRESS, 1);     // In this case only read one byte
  byte bRetVal = Wire.read(); 
  return bRetVal;
}

void write_byte(byte bAdress,byte bValue)
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS); 
  Wire.write(0x08+bAdress);                             // Set the register pointer to (0xf3) to write the 11th memory byte
  Wire.write(bValue);                             // Write the desired byte value
  Wire.endTransmission();
}


With regards to writing new values to the EEPROM without uploading new sketches, how is that done?

if I proceeded with the IF else statements, would it still be possible? Like if I add a "second" reading, and add it to the test, such as, "hour == 8 && minute == 30 && second == 01"? And just upload a new sketch every time i wanted to change the alarm times?
9  Using Arduino / Project Guidance / Re: DS1307 as an alarm. on: February 06, 2013, 09:21:15 am
You've got a point there... Hmmm... Here's my solution:

Since the pin would be 60 times as high as you mentioned, and I wanted a 1 second interruption, ill just make the pin HIGH for 16 mS. So that 60*16 = 960mS, around 1 second. smiley-grin

as for the other codes, would that be a valid code sequence? Like for example, I wanted for different times, i just keep adding "if" statements?
10  Using Arduino / Project Guidance / DS1307 as an alarm. on: February 06, 2013, 08:42:25 am
Guys, im trying to build an alarm based on the DS1307 RTC.

My plan is this, to have an alarm that would alarm at specific times as i have inputted them already.

I ordered the module, and im excited to use it, but i wanted to get a jump start from you guys.

My plan to create this project is to read the time from the RTC, such as:

Code:
int hour = now.hour()
int minute = now.minute()

correct?

then, run it through an if statement, like say, i wanted it to ring the alarm at say, 0830, the could would be like:

Code:
if hour == 8 && minute == 30
{
digitalWrite(alarmPin, HIGH);
delay(1000);
digitalWrite(alarmPin, LOW;
}

correct?

smiley
11  Using Arduino / Project Guidance / Re: Making a 0-12v & 0-5v pulse on: January 29, 2013, 09:37:35 pm
Schematic?

12  Using Arduino / Project Guidance / Re: Making a 0-12v & 0-5v pulse on: January 29, 2013, 08:32:07 pm

I want to use an arduino, either a mega or an UNO R3, to make both signals at the same time. I know a mechanical relay would not be capable of running the necessary frequencies (0 - 100khz-ish), so how would I do this? Transistors?


Better use MOSFETs, they're more efficient in switching, faster, too. Provides more power if you need it, aswell.

Good luck on the project! Quite ambitious, but FUN! Post some pictures!

Would a mosfet like this work ? http://www.radioshack.com/product/index.jsp?productId=2062618
What would I do with each of the pins? I need a fritzing diagram!

As for the project, take a look here smiley http://www.s2ki.com/s2000/topic/975497-wait-that-isnt-an-f20c/

The MOSFETs would be used for voltage isolation, protects the Arduino pin, too. In case of a higher voltage pulsing that is required to the system, the MOSFET would help.

On the fritzing diagram attached, your output to the system would be on the middle pin, and the battery pack could also be 12V.
13  Using Arduino / Project Guidance / Re: Making a 0-12v & 0-5v pulse on: January 27, 2013, 10:24:55 pm

I want to use an arduino, either a mega or an UNO R3, to make both signals at the same time. I know a mechanical relay would not be capable of running the necessary frequencies (0 - 100khz-ish), so how would I do this? Transistors?


Better use MOSFETs, they're more efficient in switching, faster, too. Provides more power if you need it, aswell.

Good luck on the project! Quite ambitious, but FUN! Post some pictures!
14  Using Arduino / Microcontrollers / Re: 24C04 and Arduino on: December 11, 2012, 09:26:48 pm
Thanks for the reply.

So, is the 24C04 similar to the ATtiny line of chips? For example, i would like to blink a LED on and off, is that possible?
15  Using Arduino / Microcontrollers / 24C04 and Arduino on: December 11, 2012, 08:44:06 pm
Hey guys! I want to lessen the size of my projects, and with my research, the ATtiny series of uCs can be programmed by the arduino, and further reading has lead me that the PICAXE uCs can be programmed by the arduino as well. I want to try them out, but, sad to say, both of them are not available in my place. PIC is also on my list, but the programmer is expensive, and not in the range of my budget at the moment, and I wouldn't like to invest on something that might be out from the market soon, as the arduino can program both.

Now, going around the electronic supply stores here, I came across a chip, it model number is 24C04, and asking the technicians in the store, they are used in some TVs, and they have to be programmed. I took a look at their programmer, and it was a copier, and it uses an ATMEL chip. Now, i was wondering, if i could program it using my arduino. Could it?

Thanks guys!
Pages: [1] 2