Recent Posts

Pages: 1 2 3 [4] 5 6 ... 10
31
I want to use 4 DC Motors regulated by a joystick, a servo motor commanded by a push-button, and all data sent by an nrf24l01. This is a copy of my question on another group (guessed that group).

Transmitter code:

Code: [Select]
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define joyV A0
#define joyH A1
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

int joyposV = 512;
int joyposH = 512;

RH_NRF24 RadioDriver;
RHReliableDatagram RadioManager(RadioDriver, CLIENT_ADDRESS);

uint8_t motorcontrol[3];
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];

void setup() {
  // put your setup code here, to run once:
  pinMode(3,INPUT);
  if(!RadioManager.init())
  motorcontrol[2] = 0;
}

void loop() {
  // put your main code here, to run repeatedly:
  joyposV = analogRead(joyV);
  joyposH = analogRead(joyH);

  if(joyposV < 460){
    motorcontrol[2] = 1;

    motorcontrol[0] = map(joyposV, 460, 0, 0, 255);
    motorcontrol[1] = map(joyposV, 460, 0, 0, 255);
  }
  else if(joyposV > 564){
    motorcontrol[2] = 0;

    motorcontrol[0] = map(joyposV, 564, 1023, 0, 255);
    motorcontrol[1] = map(joyposV, 564, 1023, 0, 255);
  }
  else{
    motorcontrol[0] = 0;
    motorcontrol[1] = 0;
    motorcontrol[2] = 0;
  }

  if(joyposH < 460){
    joyposH = map(joyposH, 460, 0, 0, 255);

    motorcontrol[0] = motorcontrol[0] - joyposH;
    motorcontrol[1] = motorcontrol[1] + joyposH;

    if(motorcontrol[0] < 0)motorcontrol[0] = 0;
    if(motorcontrol[1] > 255)motorcontrol[1] = 255;
  }
  else if(joyposH > 564){
    joyposH = map(joyposH, 564, 1023, 0, 255);

    motorcontrol[0] = motorcontrol[0] + joyposH;
    motorcontrol[1] = motorcontrol[1] - joyposH;

    if(motorcontrol[0] > 255)motorcontrol[0] = 255;
    if(motorcontrol[1] < 0)motorcontrol[1] = 0;
  }

  if(motorcontrol[0] < 8)motorcontrol[0] = 0;
  if(motorcontrol[1] < 8)motorcontrol[1] = 0;

  if(RadioManager.sendtoWait(motorcontrol, sizeof(motorcontrol), SERVER_ADDRESS)){
    uint8_t len = sizeof(buf);
    uint8_t from;
  }
  delay(50);
}


Receiver:

Code: [Select]
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

int enA = 9;
int in1 = 14;
int in2 = 4;

int enB = 5;
int in3 = 7;
int in4 = 6;

RH_NRF24 RadioDriver;

RHReliableDatagram RadioManager(RadioDriver, SERVER_ADDRESS);

uint8_t ReturnMessage[] = "JoyStick Data Received";

uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];

void setup() {
  // put your setup code here, to run once:
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(RadioManager.available()){
    uint8_t len = sizeof(buf);
    uint8_t from;
    if(RadioManager.recvfromAck(buf, &len,&from)){
      if(buf[2] == 1){
        digitalWrite(in1, LOW);
        digitalWrite(in2, HIGH);
        digitalWrite(in3, LOW);
        digitalWrite(in4, HIGH);
      }
      else{
        digitalWrite(in1, HIGH);
        digitalWrite(in2, LOW);
        digitalWrite(in3, HIGH);
        digitalWrite(in4, LOW);
      }
      analogWrite(enA, buf[1]);
      analogWrite(enB, buf[0]);
    }
  }
}
32
Français / Re: Faux circuits sur Ebay et ...
Last post by hbachetti - Today at 06:38 pm
Quote
Jamais je n'aurai acheté les produits que tu as acheté : tout est tordu !
C'est vrai on dirait que c'est soudé avec les pieds.
Je connaissais le logiciel codé avec les pieds, mais pas la soudure  :smiley-mr-green:
33
Thanks.  So I tried moving the esp/wifi setup code from the setup() to the postCloudData() function thinking the whole esp setup would happen each time the UNO is ready to post, and well, I let it run and at least it posted 4 entries instead of 1 like before.

And yes I understand I can use the ESP by itself, I actually have a set up where it posts data to an instance of emoncms and it has been doing so for quite a while flawlessly.  I just wanted to try other options. 

Unfortunately my project collected data from a dht11 but it also uses radio to send data from the warehouse its located in, remotely, to a receiving UNO which is the one that posts to the cloud.  So the esp wouldnt have space to accept so many pins from the nrf24 module. 

Ill keep messing with it.
34
Español / MOVED: Leer datos alarma linea...
Last post by surbyte - Today at 06:36 pm
35
Hardware / Re: Leer datos alarma linea te...
Last post by surbyte - Today at 06:36 pm
No hiciste mas que pasar de 4 a 9 lìneas pero sigues sin decir nada lo suficientemente útil.

Te voy a orientar porque veo que no te das cuenta de lo que te solicito.

1) lee las normas del foro, ellas te piden que cuando plantees algo lo expliques debidamente, y còmo es eso o còmo se hace eso?

2) Tienes una central de alarma: Qué marca y modelo? tiene página web, entonces la pones (usando etiquetas), tiene manual, entonces lo subes como adjunto.. se comprende?

Entonces con Marca y modelo de tu alarma TAL VEZ y solo tal vez podamos decirte... ahh no sabemos nada o sí, que tal si haces esto o lo otro.

Ojalá ahora tengas una mejor idea de lo que te pido!!
36
Project Guidance / Re: UV Light exposure unit
Last post by larryd - Today at 06:34 pm
What is currently "working" ?



37
I have three transmitters, each a different address transmitting different information. I am attempting to scan for new data from each transmitter. I am receiving the messages from the wrong receivers most of the time. It works fine if I only listen to one transmitter for a while, but to check each address one right after the other results in reading the wrong data.

Code: [Select]
#include <nRF24L01.h>
#include <RF24.h>
bool newData = false;//used to indicate that new data has arrived from the radio
char data[12];//data recieved from radio goes here
byte radioAddress[5] = {'A', 'S', 'C', 'i', 'i'};
RF24 radio(7, 8);

void setup() {
  Serial.begin(115200);
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate( RF24_250KBPS );
  radio.printDetails();
  delay(1000);
}

void loop() {
  radioAddress[0] = 'A';
  getData();
  if (newData == true) {
    Serial.print("Outside data = ");
    Serial.println(data);
  }

  radioAddress[0] = 'B';
  getData();
  if (newData == true) {
    Serial.print("Crawlspace data = ");
    Serial.println(data);
  }

  radioAddress[0] = 'C';
  getData();
  if (newData == true) {
    Serial.print("Timestamp = ");
    Serial.println(data);
  }
}


void getData() {
  radio.openReadingPipe(1, radioAddress);
  radio.startListening();
  if ( radio.available() ) {
    radio.read( &data, sizeof(data) );
    newData = true;
  } else newData = false;
}



I wonder why I can't switch addresses on the fly like this? I have a different project where I do switch addresses that does work, but the only difference is that I switch and stay switched until I see the data I was looking for.

I am probably going to modify the transmitters to all use the same address but add a identifier byte to the data. Probably the best way to go, as I may have more than six transmitters eventually. I considered using pipes, but I have not found a good explanation that shows me how to do it, and six transmitters might not be enough.

Any ideas on why the radio would receive the data from the wrong address in my code above? I'd like to make it work, even if I do switch to an identification byte/single address system.
38
You may try a different library. I use the one of adafruit, it is easy to use and you won't have any issues with delay() functions

Go to tools -> Manage Libraries -> type dht and install the adafruit library





39
Deutsch / Re: Arduino mehrere LEDs anste...
Last post by Rentner - Today at 06:31 pm
Hallo,

wie combie schon schrieb Abb2 ist ok

bei abbildung 1 ist der Widerstand ja nur im linken Teil enthalten rechts ist keiner drin

Heinz
40
Deutsch / Re: Arduino mehrere LEDs anste...
Last post by postmaster-ino - Today at 06:31 pm
Hi

Hat sich die Bildreihenfolge verändert??

Nun ist
Bild 1 ist bäh!
Da fehlt die Strombegrenzung - die LED-Kette liegt nur an Vdd und GND - sobald die Fluß-Spannung überschritten wird, 'springen' die LEDs an und nehmen 'unendlich viel' Strom - ok, irgend etwas stirbt dabei, dann ist wieder aus.

In Bild 2 hast Du zwei LED-Ketten an jeweils eigenem Vorwiderstand - beide Schaltungen 'sehen' Nichts voneinander - Die laufen normal an der Versorgungsspannung.

Diese muß größer als die Summe der Fluß-Spannungen sein - das 'Zuviel' muß bei dem gewünschtem Strom am Vorwiderstand abfallen - R=UxI.
Dabei ist darauf zu achten, daß dieses 'zu viel an Spannung' nicht zu Wenig wird, damit der Widerstand auch eine Chance hat, bei kleinen Stromänderungen relativ große Spannungabfälle zu erzeugen.

Auf Deutsch: Vcc=Summe Fluß-Spannungen (oder nur minimal größer), damit man einen möglichst kleinen Widerstand benutzen kann, ist nicht zielführend.
Eine LED Reserve (also die Fluß-Spannung dazu) sollte schon vorhanden sein.

MfG

PS: Aso - ein gemeinsamer Vorwiderstand - ne, Das gibt Keinen, da Du so zwar halbwegs den Strom des Gesamten begrenzen kannst, aber kaum eine Handhabe hast, wie sich Dieser unter den LED-Gruppen aufteilt - ich tendiere zu 100%, 0% - da die Fluß-Spannung der einen Gruppe kleiner sein wird, als die Spannung der Anderen.

PPS: Ggf. hatte ich die Bilder auch nur in der falschen Reihenfolge geöffnet??
Pages: 1 2 3 [4] 5 6 ... 10