Im doing visually empaired people helper project and it means using SharpIR + Ultrasonic + GPS Neo6mv2 + GSM sim808 and i have 2 code and icant connect them. Help me?
versionv2.1.ino (1.69 KB)
gps.ino (2.52 KB)
Im doing visually empaired people helper project and it means using SharpIR + Ultrasonic + GPS Neo6mv2 + GSM sim808 and i have 2 code and icant connect them. Help me?
versionv2.1.ino (1.69 KB)
gps.ino (2.52 KB)
Help me?
No. You have not said what either program actually does. You have not said what the final program is supposed to do. You have not said what it actually does. How can we help with so little information?
#include <SoftwareSerial.h>
#include "SIM900.h"
#include <TinyGPS.h>
#include "sms.h"
SMSGSM sms;
TinyGPS gps;
SoftwareSerial ss(4, 3);
SoftwareSerial SIM900(7, 8);
static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);
String strL, strN, message, textForSMS;
char charL[10], charN[10], text[200];
int m = 1;
boolean started = false;
void setup()
{
Serial.begin(9600);
ss.begin(9600);
gsm.begin(9600);
}
void loop()
{
float flat, flon;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
gps.f_get_position(&flat, &flon, &age);
textForSMS = "Moosa Home"; //testing gps from here
Serial.println(textForSMS);
Serial.println(flat, 6);
Serial.println(flon, 6);
Serial.print("longitude: ");
print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
Serial.println("");
Serial.print("latitude : ");
print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
smartdelay(1000);
Serial.println(""); //till here
delay(1000);
if (m == 5) //send sms on third reading
{
Serial.println("XXXXXXXXX"); //to check whether 'if' works
dtostrf(flat, 4, 6, charL);
for (int i = 0; i < 10; i++)
{
strL += charL[i];
}
dtostrf(flon, 4, 6, charN);
for (int i = 0; i < 10; i++)
{
strN += charN[i];
}
message = "Home";
message = message + "/nLat: ";
message = message + strL;
message = message + "/nLon: ";
message = message + strN;
message.toCharArray(text, 250);
Serial.println(text);
if (sms.SendSMS("+999999999999999", text))
{
Serial.println("\nSMS sent OK.");
}
else
{
Serial.println("\nError sending SMS.");
}
do {} while (1);
}
m++;
}
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}
static void print_float(float val, float invalid, int len, int prec)
{
if (val == invalid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
{
Serial.print(val, prec);
int vi = abs( val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i = flen; i < len; ++i)
Serial.print(' ');
}
smartdelay(0);
}
static void print_str(const char *str, int len)
{
int slen = strlen(str);
for (int i = 0; i < len; ++i)
Serial.print(i < slen ? str[i] : ' ');
smartdelay(0);
}
#define trigPin 4
#define echoPin 2
int bipPin = 8;
int bipPin1 = 9;
int Note = 1;
int Nate = 1800;
int Nite = 1600;
int IRpin = A0; // sensor to pin A0
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 400 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" ult");
}
if(distance<=120 && distance>=100)
{
tone(bipPin, 20, 30);
}
if(distance<=100 && distance>=65)
{
tone(bipPin, 50, 60);
}
if(distance<65 && distance>30)
{
tone(bipPin, 100, 100);
}
if(distance>0 && distance<30)
{
tone(bipPin, 1, 1);
}
{
float volts = analogRead(IRpin)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
float distance = 65*pow(volts, -1.10); // worked out from graph 65 = theretical distance / (1/Volts)S
Serial.print(distance);
Serial.println(" shp");
if(distance<40 && distance>10)
{
tone(bipPin1, Nate, distance);
}
if(distance>40 && distance<70)
{
tone(bipPin1, Note, distance);
}
if(distance>70 && distance<100)
{
tone(bipPin1, Nite, distance);
}
if(distance>100 && distance<300)
{
tone(bipPin1, Nite, distance);
}
delay(200); // arbitary wait time.
}
delay(200);
}
Why icant ? I wrote sharpir+ultrasonic
and gps+gsm just connect this 2 codes and need sensor codes must be contuinously
anhbaysgalan:
Why icant ? I wrote sharpir+ultrasonic
and gps+gsm just connect this 2 codes and need sensor codes must be contuinously
Apparently, English isn't your first language. But, spacing between words is not language dependent...
Yes, you have two codes. No, you do NOT have requirements for the resulting program. No, you have not made any attempt to combine them. Nor are you likely to be successful without any requirements.
Any code that uses two instances of SoftwareSerial is doomed to failure from the get go. Get an Arduino with multiple hardware serial ports, and do not use software serial at all.
First, I suggest you resolve the pin conflicts.
#define trigPin 4
#define echoPin 2
int bipPin = 8;
int bipPin1 = 9;
SoftwareSerial ss(4, 3);
SoftwareSerial SIM900(7, 8);