Hi There,
I’m relatively new to Arduino programmming and already have a nice project.
I want to read data from a adafruit guva-s12sd UV Sensor, calculate the energy in mW/cm2 and display it on a 7 digits serial display (Sparkfun).
Here’s my error code. It says:
Arduino: 1.6.5 (Windows 7), Platine: “Arduino Duemilanove or Diecimila, ATmega328”
_20150909_Programm_UV-Sensor.ino: In function ‘void loop()’:
_20150909_Programm_UV-Sensor:25: error: ‘disp’ was not declared in this scope
_20150909_Programm_UV-Sensor:26: error: ‘setDecimals’ was not declared in this scope
_20150909_Programm_UV-Sensor:28: error: expected ‘;’ before ‘}’ token
‘disp’ was not declared in this scope
The code is:
#include <SoftwareSerial.h>
void setup()
{
// These are the Arduino pins required to create a software seiral
// instance. We’ll actually only use the TX pin.
const int softwareTx = 8;
const int softwareRx = 7;
SoftwareSerial disp(softwareRx, softwareTx);
// Must begin s7s software serial at the correct baud rate.
// The default of the s7s is 9600.
Serial.begin(9600);// open serial port, set the baud rate to 9600 bps
disp.begin(9600);
// Clear the display, and then turn on all segments and decimals clearDisplay(); // Clears display, resets cursor
}
void loop()
{
int UV;
UV = analogRead(A0);//connect UV sensors to Analog 0
int Watt = (UV * 0.0042 * 0,4778);
disp.print(Watt); // Displays Watt Value
setDecimals(0b00000100);
delay(200)
}
In the attachment, you will find the wiring. What I am doing wrong?
You are right, there is somthing wrong with the float variable.
For the conversion I suggested the result is mW expressed in integer.
What do you want to use the microWatt part for?
To display it in 4 digits?
What should be displayed for a value of 1,1338?
Why did you change the conversion factor from 2.00676 to 0,0087890625 (9/1024)?
Yes, I want to display the mW on the 4 digits display.
The conversion factor changed, because I found an error in my calculation. This is the right conversion factor now.
RobNie:
The only Problem I have now is, ther are no decimal points on the display. Actually, there are decimal points, but the code did not use them...
Thanks!
YOU (as a creator of your code) did not advise the display to show them.