PLEASE HELP V3 | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
PLEASE HELP V3
No permission to create posts
November 2, 2018
3:17 am
Avatar
KingVic
New Member
Members
Forum Posts: 4
Member Since:
October 11, 2018
sp_UserOfflineSmall Offline

HI everyone,

Forgive me for i am completely noob to arduino, Im trying to get the servo to work, but the ServoTimer2.h library seems to clash with something in my sketch. PLEASE HELP.

Here is my client code:
#include
#include "DHT.h"
#include
#define DHTTYPE DHT11

//#include
//#include
#include
#include

#include
#include
#include
#include
#include
#define MINUTE_VALUE 1

RH_RF95 rf95;

//#### PIR ####
int PIR1 = A3;
int PIR2 = A4;
int PIR3 = A5;
int state = LOW; // by default, no motion detected
int sam, isam;
int state1 = LOW, state2 = LOW;

int i = 0; // variable to store the sensor status (value)
int counter = 0, backup = 0;
int second = 0, minute = 0;
int flag_status = 0;

//#### DHT ####
#define DHT_Pin A0
DHT dht(DHT_Pin, DHTTYPE);
byte Err = 0;
char node_ID[3] = {1,2,5};
float frequency = 868.0;
unsigned int count = 1;
float read_Tem;
float read_Hum;
char dht_data[4];

//#### SDM ####
const int soundPin = A1;
//int DPin = 2;
float dbValue;
char db_data[2];

//#### For Internal Temperature Sensor and Servo ####
/*const int sensePin = A2;
int sensorInput = 0; //The variable we will use to store the sensor input
double Temp; //The variable we will use to store temperature in degrees.
*/
int servoPin1 = 3;
int servoPin2 = 5;
servos servo1;
servos servo2;

//#### UV ####
const int UVPin = A2;
float sensorValue_UV;
float UV_index;
char uv_data[2];

void setup()
{
Serial.begin(9600);
pinMode(PIR1, INPUT);
pinMode(PIR2, INPUT);
pinMode(PIR3, INPUT);
servo1.attach(servoPin1);
servo2.attach(servoPin2);
dht.begin();
Timer1.initialize(1000000);
Timer1.attachInterrupt(PIR_data_Upload);

}
void loop()
{
Inital();
Read_DHT();
Upload_to_Gateway();
MeasuredSound();
readVcc();
servo();
sensor_UV();
PIR_data_Upload();
sensor1();
sensor2();
sensor3();
}
void Inital()
{

if(!rf95.init())
{
Serial.println("Initial Failed");
}
rf95.setFrequency(frequency); //Setup ISM Frequency
rf95.setTxPower(13); //Setup for Power (dBm)

Serial.println("##### Sai and Vichai Project #####");
Serial.print("LoRa End Node ID: ");
for(int i = 0; i<3; i++)
{
Serial.print(node_ID[i], HEX);
}
Serial.println();
}

void Upload_to_Gateway()
{
Read_DHT();
MeasuredSound();
Serial.print("########### ");
Serial.print("COUNT= ");
Serial.print(count);
Serial.println(" ###########");
count++;

char send_Data[100] = {0};
char PIR_data[10] = {0};
int datalength = sizeof(send_Data);
if (flag_status)
{
backup = counter;
PIR_data[0] = backup;
flag_status = 0;
}

send_Data[0] = node_ID[0]; //Node ID
send_Data[1] = node_ID[1]; //Node ID
send_Data[2] = node_ID[2]; //Node ID

send_Data[3] = dht_data[0]; //Temperature
send_Data[4] = dht_data[1]; //Humidity

send_Data[5] = db_data[0]; //Sound Integar
send_Data[6] = db_data[1]; //Sound Decimal

send_Data[7] = uv_data[0]; //UV Integar
send_Data[8] = uv_data[1]; //UV Decimal

send_Data[9] = PIR_data[0]; //PIR counting value

Serial.print("Temperature = ");
Serial.print(send_Data[3], DEC);
Serial.println(" C ");
Serial.print("Humidity = ");
Serial.print(send_Data[4], DEC);
Serial.println(" % ");
Serial.print("Sound = ");
Serial.print(send_Data[5], DEC);
Serial.print(".");
Serial.print(send_Data[6], DEC);
Serial.println(" dB ");
Serial.print("UV = ");
Serial.print(send_Data[7], DEC);
Serial.print(".");
Serial.print(send_Data[8], DEC);
Serial.println(" mV ");
Serial.print("Human = ");
Serial.print(send_Data[9], DEC);
Serial.println(" Idoits ");
delay(1000);

unsigned char send_Buf[200] = {0};
for(int i = 0; i0)return(decPart); //return the decimal part of float number if it is available
else if(decPart<0)return((-1)*decPart); //if negative, multiply by -1
else if(decPart=0)return(00); //return 0 if decimal part of float number is not available
}

void sensor_UV()
{
sensorValue_UV = analogRead(UVPin);
UV_index = sensorValue_UV/1024*5;

uv_data[0] = int(UV_index);
uv_data[1] = getDecimal(UV_index);
/*
Serial.print("UV_index = ");
Serial.println(UV_index);
Serial.print("uv int = ");
Serial.println(uv_data[0],DEC);
Serial.print("uv dec= ");
Serial.println(uv_data[1],DEC); // Get Decimal part
Serial.println("#############");
delay(1000);
*/
}

long readVcc()
{
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif

delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA,ADSC)); // measuring

uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both

long result = (high<= 22)
{
// servo1.write(170);
// servo1.write(170);
}
else if(read_Tem <= 20)
{
// servo2.write(5);
// servo2.write(5);
}
}

void PIR_data_Upload()
{
second++;
if (second == 59)
{
second = 0;
minute++;
}
if (minute == MINUTE_VALUE)
{
second = 0;
minute = 0;
flag_status = 1;
}
}
void sensor1()
{
i = digitalRead(PIR1); // read sensor value
if (i == HIGH)
{ // check if the sensor is HIGH

delay(100); // delay 100 milliseconds

if (state == LOW)
{
Serial.println("SENSOR 111 is detected!");
state = HIGH; // update variable state to HIGH
counter++;

}
}
else
{
delay(200); // delay 200 milliseconds

if (state == HIGH)
{
Serial.println("SENSOR 111 is stopped!");
state = LOW; // update variable state to LOW
}
}
}

void sensor2()
{
sam = digitalRead(PIR2); // read sensor value
if (sam == HIGH)
{ // check if the sensor is HIGH
delay(100); // delay 100 milliseconds

if (state1 == LOW)
{
Serial.println("SENSOR 222 is detected!");
state1 = HIGH; // update variable state to HIGH
counter++;
}
}
else
{
delay(200); // delay 200 milliseconds

if (state1 == HIGH)
{
Serial.println("SENSOR 222 is stopped!");
state1 = LOW; // update variable state to LOW
}
}
}

void sensor3()
{
isam = digitalRead(PIR3); // read sensor value
if (isam == HIGH)
{ // check if the sensor is HIGH
delay(100);

if (state2 == LOW)
{
Serial.println("SENSOR 333 is detected!");
state2 = HIGH; // update variable state to HIGH
counter++;
}
}
else
{
delay(200); // delay 200 milliseconds

if (state2 == HIGH)
{
Serial.println("SENSOR 333 is stopped!");
state2 = LOW; // update variable state to LOW
}
}

}

THIS IS THE ERROR MESSAGE I KEEP GETTING

ketch_CLIENT_V9119:57: error: 'servos' does not name a type

servos servo1;

^

Sketch_CLIENT_V9119:58: error: 'servos' does not name a type

servos servo2;

^

C:\Users\Admin\Desktop\WORK\MECH468\Sketch_CLIENT_V9119\Sketch_CLIENT_V9119.ino: In function 'void setup()':

Sketch_CLIENT_V9119:72: error: 'servo1' was not declared in this scope

servo1.attach(servoPin1);

^

Sketch_CLIENT_V9119:73: error: 'servo2' was not declared in this scope

servo2.attach(servoPin2);

^

Multiple libraries were found for "Adafruit_Sensor.h"
Used: C:\Users\Admin\Documents\Arduino\libraries\Adafruit_Unified_Sensor
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Unified_Sensor-1.0.2
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Unified_Sensor-1.0.2
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Unified_Sensor-1.0.2
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Unified_Sensor-1.0.2
exit status 1
'servos' does not name a type

November 2, 2018
3:51 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 477
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Now that we are on v3, I think you have to drop the noob 🙂
Id look into this error:
"'servos' does not name a type."
Usually that happens when you try to declare a type of variable that doesn't exist. Please let us know if you got it working.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
38 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

JerilynDernnida, JaketripDernnida, KenterDernnida, AlisaMiz, AriurinDernnida, KabinaDernnida

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457