Hello Paul again,
I get the ideer you get my problem. It is not that you didn,t understand the problem but more the way i explained the case. I found it hard to exppain the problem in such a way that somewone else also can understand the problem.
First of al i wil reply to you in a desent maner that means scripts in the scripts format. here we go
//Teller programma voor windrichting
//DD 29-12-2010
//xbee_send_teller_serial
//zonder display
//met serial voor xbee te zenden naar coordinater
//probleem interrupt 5 op pin 18 checken nu middels input opgelost
//display dusdanig aansluiten dat interrupt niet in de weg zitten
//vervalt dus ook IR sensor noord set op input 4
//bij opstarten eerst een volle slag maken met e wind vaan.
//#include <ctype.h>
#include <LiquidCrystal.h>
#define encoder0PinA 2 // interrupt
#define encoder0PinB 3 // interrupt
//const int set0Pin = 4; // noord set (16) IR sensor
#define encoder0PinC 18 // interrupt 5 op pin 18
volatile unsigned int encoder0Pos = 16;
unsigned int tmp_Pos = 0;
LiquidCrystal lcd(6, 7, 8, 9, 10, 11, 12);
// arduino 6 min 8 9 10 11 12
// display 4 5 6 11 12 13 14
const int numRows = 4;
const int numCols = 20;
int led = 13; // for checking nul ""o"" doorgang
boolean A_set;
boolean B_set;
void setup() {
pinMode(encoder0PinA, INPUT);
pinMode(encoder0PinB, INPUT);
// pinMode(set0Pin, INPUT);
pinMode(led, OUTPUT);
// encoder pin on interrupt 0 (pin 2)
attachInterrupt(0, doEncoderA, CHANGE);
// encoder pin on interrupt 1 (pin 3)
attachInterrupt(1, doEncoderB, CHANGE);
// encoder pin on interrupt 5 (pin 18)
attachInterrupt(5, doEncoderC, CHANGE);
lcd.begin(numCols, numRows);
Serial.begin (9600);
// char windValue = encoder0Pos;
}
void loop(){
//Check of wind vaan door de noord gaat?
// intterrupt oplijnen op interrupt 5 en input 18 zie teller_019 o.i.d.
// e.e.a. om van 16 tot 31 te kunnen en blijven tellen tellen omdat bij set
// at encoderPinC we niet terug aftellen minder dan 16 .
// if (encoder0Pos == 15) {
// encoder0Pos = encoder0Pos +16;
Serial.begin(9600);
// char windValue;
// Serial.print(windValue, DEC);
//Check for change in position
if (tmp_Pos != encoder0Pos) {
Serial.print("Teller:"); Serial.println(encoder0Pos, DEC);
if (encoder0Pos == 16) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("16NOORD");
// delay(1000);
}
if (encoder0Pos == 17) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("17NoordNoordOost");
// delay(1000);
}
if (encoder0Pos == 18) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("18NoordOostNoord");
// delay(1000);
}
if (encoder0Pos == 19) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("19NoordOostOost");
// delay(1000);
}
if (encoder0Pos == 20) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("20OOST");
// delay(1000);
}
if (encoder0Pos == 21) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("21OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 22) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("22ZuidOostZuid");
// delay(1000);
}
if (encoder0Pos == 23) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("23ZuidZuidOost");
// delay(1000);
}
if (encoder0Pos == 24) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("24ZUID");
// delay(1000);
}
if (encoder0Pos == 25) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("25WestZuidZuid");
// delay(1000);
}
if (encoder0Pos == 26) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("26OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 27) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("27OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 28) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("28OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 29) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("29OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 30) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("30OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 31) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("31OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 32) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("32OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 33) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("33OostOostZuid");
// delay(1000);
}
if (encoder0Pos == 34) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("34NoordWestNoord");
// delay(1000);
}
if (encoder0Pos == 35) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("35NoordNoordWest");
// delay(1000);
}
}
tmp_Pos = encoder0Pos;
}
// Interrupt on A changing state
void doEncoderA(){
// Low to High transition?
if (digitalRead(encoder0PinA) == HIGH) {
A_set = true;
if (!B_set) {
encoder0Pos = encoder0Pos + 1;
}
}
// High-to-low transition?
if (digitalRead(encoder0PinA) == LOW) {
A_set = false;
}
}
// Interrupt on B changing state
void doEncoderB(){
// Low-to-high transition?
if (digitalRead(encoder0PinB) == HIGH) {
B_set = true;
if (!A_set) {
encoder0Pos = encoder0Pos - 1;
{
if (encoder0Pos < 16){
// tmp_Pos= tmp_Pos +16;
encoder0Pos= encoder0Pos+20;
}
}
}
}
// High-to-low transition?
if (digitalRead(encoder0PinB) == LOW) {
B_set = false;
}
}
void doEncoderC() {
if (digitalRead(encoder0PinC) == LOW) {
digitalWrite( led ,HIGH);
encoder0Pos = 16;
} else{ digitalWrite( led, LOW);}
}
this was the wind script following the display script
/*
xbee_recieve_serial_data_test_02
Language: Arduino
Tested op board Duemi met display XBEE als coordinater 1047 recieve.
Duemi als sender met SHT en XBEE als router end device 1247 send
DD 29 dec. 2010
E.e.a. t.b.v. meteo project. default in XBEE geladen en panid en ni opnieuw geprog.
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(6,7,8,9,10,11,12);
// display 4 5 6 11 12 13 14
// arduino 6 min 8 9 10 11 12
volatile unsigned int encoder0Pos;
char tCValue1;
char tCValue2;
char rhTrueValue1;
char rhTrueValue2;
char DauwpuntValue1;
char DauwpuntValue2;
int incomingByte[15]; // Serial data array met plaats voor 15 bytes
char inByte = 0;
void setup()
{
lcd.begin(4,16); // LCD rows and colomns
lcd.clear(); // LCD leeg maken
lcd.setCursor(0,0);
// 1234567890123456
lcd.print("Temp. :");
lcd.setCursor(0,1);
// 1234567890123456
lcd.print("Vochtigh:");
lcd.setCursor(-4,2);
// 1234567890123456
lcd.print("Dauwpunt:");
lcd.setCursor(-4,3);
// 1234567890123456
lcd.print("Wind :");
}
void loop()
{
Serial.begin(9600);
if (Serial.available() > 0) { // get any incoming data:
for (int i=0; i<11; i++) { // elf stuks bytes laden in array
inByte = Serial.read();
incomingByte = inByte;
Serial.print(inByte); // voor de serial port
}
}
tCValue1=(incomingByte[1]); // eerste char byte van de temp
tCValue2=(incomingByte[2]); // tweede char byte van de temp
rhTrueValue1=(incomingByte[4]);
rhTrueValue2=(incomingByte[5]);
DauwpuntValue1=(incomingByte[7]);
DauwpuntValue2=(incomingByte[8]);
for ( int i=0; i<11; i++) // uitlezen van de array
{
lcd.setCursor(9,0);
lcd.print (tCValue1); // print to LCD
lcd.setCursor(10,0);
lcd.print (tCValue2);
lcd.setCursor(9,1);
lcd.print(rhTrueValue1);
lcd.setCursor(10,1);
lcd.print(rhTrueValue2);
lcd.setCursor(5,2);
lcd.print(DauwpuntValue1);
lcd.setCursor(6,2);
lcd.print(DauwpuntValue2);
lcd.setCursor(5,3);
lcd.print(encoder0Pos);
}
}
As the max of the message is there i will make a new post for the sensor SHT script.