Hallo
Ich möchte eine Lichtsschranke bauen, welche, wenn sie durchbrochen
wird, ein Funksignal mit einem NRF24L01 an einen Arduino Uno schickt.
Ich habe eine Platine gelötet und das ganze hat auch funktioniert, doch
seit ich sie aufstellen wollte und die Platine mit Klebeband an einen
Batterietank(4,5V) geklebt habe, funktioniert gar nichts mehr. Ich habe
fast alle Drähte ausgetauscht, den NRF24L01 neu verkabelt und die ISP
Header entfernt( die Software funktionierte ja schon und ohne den
Headern ist es übersichtlicher),trotzdem keine Verbesserung! Im Anhang
sind noch Fotos der Platine zu finden!
Hier die Software:
1 | #include <SPI.h>
|
2 | #include <RF24.h>
|
3 | #include <nRF24L01.h>
|
4 | #include <RF24_config.h>
|
5 |
|
6 | RF24 radio(9,10);
|
7 |
|
8 | int la[10];
|
9 | int lConst=0;
|
10 | void setup(){
|
11 | radio.begin();
|
12 | radio.setChannel(2);
|
13 | if (radio.isPVariant())
|
14 | {
|
15 |
|
16 | }
|
17 | else
|
18 | {
|
19 |
|
20 | }
|
21 | radio.openWritingPipe(0xF0F0F0F0D2LL);
|
22 | pinMode(0,INPUT);
|
23 | }
|
24 | int arrayAverage(int a[],int count){
|
25 | int average=0;
|
26 | int i=0;
|
27 | for(i;i<count;i++){
|
28 | average+=a[i];
|
29 | }
|
30 | return average/count;
|
31 | }
|
32 | void loop(){
|
33 | if(digitalRead(0)){
|
34 | radio.stopListening();
|
35 | char text[]="Einrichtung...";
|
36 | if (radio.write( &text,sizeof(text))){
|
37 | }else{
|
38 | }
|
39 | radio.startListening();
|
40 | int i=0;
|
41 | for(i;i<10;i++){
|
42 | la[i]=analogRead(A5);
|
43 | delay(20);
|
44 | }
|
45 | lConst=arrayAverage(la,10);
|
46 | }
|
47 | if(analogRead(A5)<lConst-10&&lConst!=0){
|
48 | radio.stopListening();
|
49 | char text[]="Lichtschranke unterbrochen";
|
50 | if (radio.write( &text,sizeof(text))){
|
51 | }else{
|
52 | }
|
53 | radio.startListening();
|
54 | delay(1000);
|
55 | }else{
|
56 |
|
57 | }
|
58 | delay(5);
|
59 | }
|
Bitte um Hilfe!