Recent Posts

Pages: [1] 2 3 ... 10
1
Deutsch / Re: StateChangeDetection und w...
Last post by combie - Today at 06:00 pm
mecker... mecker... mecker...
Und, haste dabei auch in den Spiegel geschaut?

2
Hi,

I'm not quite sure this is the right place to post, please feel free to move if there's a better forum for it.

I'm trying to read an analogue voltages with my ArduinoMega but I can't get it right and I'm not sure where the problem lies. I've found many threads on similar topics but couldn't find one what would address my issue.

No matter how I connect (or not) the analogue input pins, my Arduino always returns input values in the range of 280 to 320 (more or less) and I don't understand why. Does anyone have any ideas?

Any help is appreciated.

My setup looks like this (just in case it's a setup problem):

For now I've connected

pin3 to GND
pin6 to 5V
pin10 to 3.3V


My expectation is that I'd read the following values:

pin2: random (pin is floating)
pin2: 0
pin6: 1023
pin10: 675 (+/- a few)

A sample output looks like this:

Code: [Select]

pin2: 319 ; pin3: 320 ; pin6: 321 ; pin10: 316 ;
pin2: 324 ; pin3: 324 ; pin6: 325 ; pin10: 315 ;
pin2: 319 ; pin3: 318 ; pin6: 316 ; pin10: 305 ;
pin2: 309 ; pin3: 307 ; pin6: 303 ; pin10: 289 ;
pin2: 294 ; pin3: 292 ; pin6: 288 ; pin10: 276 ;
pin2: 284 ; pin3: 282 ; pin6: 279 ; pin10: 270 ;
pin2: 282 ; pin3: 281 ; pin6: 280 ; pin10: 274 ;
pin2: 286 ; pin3: 285 ; pin6: 285 ; pin10: 282 ;
pin2: 295 ; pin3: 296 ; pin6: 298 ; pin10: 297 ;
pin2: 311 ; pin3: 312 ; pin6: 315 ; pin10: 312 ;
pin2: 320 ; pin3: 321 ; pin6: 323 ; pin10: 317 ;
pin2: 323 ; pin3: 323 ; pin6: 324 ; pin10: 315 ;
pin2: 320 ; pin3: 319 ; pin6: 318 ; pin10: 306 ;
pin2: 311 ; pin3: 310 ; pin6: 306 ; pin10: 292 ;
pin2: 298 ; pin3: 295 ; pin6: 291 ; pin10: 278 ;
pin2: 286 ; pin3: 284 ; pin6: 281 ; pin10: 271 ;
pin2: 282 ; pin3: 280 ; pin6: 278 ; pin10: 271 ;




I'm using the code below to read the voltage at the specific pins.

Code: [Select]
// Analogue input pins
const int Sense2 = 2;
const int Sense3 = 3;
const int Sense6 = 6;
const int Sense10 = 10;

void setup() {
  // put your setup code here, to run once:

  //define pinMode for analogue input
  pinMode(Sense2, INPUT);
  pinMode(Sense3, INPUT);
  pinMode(Sense6, INPUT);

  Serial.begin(9600);
  Serial.print("Read values ->");

  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:

  String printstring1 = "";
  String printstring2 = "";

  printstring1 = "pin2: ";
  printstring2 = printstring1 + analogRead(Sense2) + " ; ";
  Serial.print(printstring2);

  printstring1 = "pin3: ";
  printstring2 = printstring1 + analogRead(Sense3) + " ; ";
  Serial.print(printstring2);

  printstring1 = "pin6: ";
  printstring2 = printstring1 + analogRead(Sense6) + " ; ";
  Serial.print(printstring2);

  printstring1 = "pin10: ";
  printstring2 = printstring1 + analogRead(Sense10) + " ; ";
  Serial.println(printstring2);

  delay(500);
}


3
Project Guidance / Re: how to wire up 36W 12V L...
Last post by Paul_KD7HB - Today at 05:58 pm
What exactly do you have in mind for the Arduino to do? Since the light is designed for a car battery, I guess you should first try a car battery and get the light to work. Surely the light came with some wiring instructions.

Paul
4
Français / Re: Joystick, commander des mo...
Last post by Devils_Kills - Today at 05:57 pm
Ton mouvement doit être une combinaison d'un mouvement longitudinal pur et d'un mouvement de rotation pure.
Donc dans le principe, dans ton programme tu devras écrire une seule fois un truc du style:

Code: [Select]

analogWrite(speedPin1, val + val2);



J'ai fais ce que vous m'avez demandé.
Mais je ne sais pas si vous avez compris, mes roues ne change pas de direction, elle se mettent seulement en marche de l'avant vers l'arrière donc on parle ici de deux mouvement longitudinales, que ce soit pour avancer ou pour tourner, car si seulement la roue de droite avance, la voiture va tourne à gauche par principe, il me faut donc que quand la valeur de val est supérieur au point de repos de l'axe Y, il faut que une des deux roues soient en marches.

Code: [Select]

    if (val2 > 320)  // donc marche arrière
    {
      val2 = map(val2, 311, 0, 0, 255);
      analogWrite(speedPin1, val + val2);
      digitalWrite(motorPin1a, HIGH);
      digitalWrite(motorPin1b, LOW);
      analogWrite(speedPin2, val2 + val);
      digitalWrite(motorPin2a, HIGH);
      digitalWrite(motorPin2b, LOW);
      Serial.print("Marche avant ");   
      Serial.print(val2,DEC);
      Serial.print(" , ");
    }
    else if(val2 < 316)
    { //marche arrière

      val2 = map(val2, 311, 0, 0, 255) ;
      analogWrite(speedPin1,val + val2); 
      digitalWrite(motorPin1a,LOW) ;
      digitalWrite(motorPin1b,HIGH);
      analogWrite(speedPin2,val2 + val);
      digitalWrite(motorPin2a,LOW) ;
      digitalWrite(motorPin2b,HIGH) ;
      Serial.print("marche arriere ");   
      Serial.print(val2,DEC);
      Serial.print(" , ");
     }

     if (val > 335)  // marche avant
     {
     
      val = map(val, 311, 0, 0, 255);
      analogWrite(speedPin1, val + val2);
      digitalWrite(motorPin1a,HIGH) ; //marche avant pour aller a droite
      digitalWrite(motorPin1b, LOW);
      Serial.print("gauche ");   
      Serial.print(val,DEC);
      Serial.print(" , ");
    }
       else if(val < 332)
      {
       
        val = map(val, 311, 0, 0, 255) ;
        analogWrite(speedPin2,val + val2 );
        digitalWrite(motorPin2a,HIGH) ; //marche avant pour aller a gauche
        digitalWrite(motorPin2b,LOW) ;
        Serial.print("droite ");   
        Serial.print(val,DEC);
        Serial.print(" , ");
      }

      else
      {
        analogWrite(speedPin1,0);
        analogWrite(speedPin2,0);
      }
   
  }// fin du if (!Mirf.isSending() && Mirf.dataReady())
} //fin loop




5
Programming Questions / Re: Using a char to indicate a...
Last post by aarg - Today at 05:57 pm
You're completely on the wrong track. The code to handle each character as a separate variable is always a mess. You should be using arrays.
6
Hi,

We are developing home automation application using Arduino.

I am sending data from my computer to my UNO. then UNO transfer the data to another arduino(Nano) through nRF24L01 radio devices.(Small one. not PA+antenna version).

computer------->UNO+nRF24L01---------------->nRF24L01+Nano.
             
              Serial            node1                     Air                  node2

Like this.


I am using maniacbuc RF library.



Tx code:
Code: [Select]

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//void radio_w(int x);
void function(int x);
RF24 radio(9, 10); // CNS, CE
const byte address[6] = "00001";
char bt;
const char text[14] = {'F', 'G', 'H', 'I', 'J', 'f', 'g', 'h', 'i', 'j', '5', '6', '7', '8'};
int AC_LOAD = 5;    // Output to Opto Triac pin
int dimming = 128;  // Dimming level (0-128)  0 = ON, 128 = OFF
int fan = 0;

void setup() {
  //  attachInterrupt(0, zero_crosss_int, RISING);
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.stopListening();
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(AC_LOAD, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(AC_LOAD, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
}

void zero_crosss_int()  //function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
  // For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65
  if (fan == 1) {
    int dimtime = (75 * dimming);  // For 60Hz =>65
    delayMicroseconds(dimtime);    // Wait till firing the TRIAC
    digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC
    delayMicroseconds(10);         // triac On propogation delay (for 60Hz use 8.33)
    digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
  }
}


void loop() {
  if (Serial.available()) {
    delay(10);
    bt = Serial.read();
  }
  if (bt == 'F') {
    function(0);
  }
  if (bt == 'G') {
    function(1);
  }
  delay(10);
  radio.startListening();
  delay(10);
}

void function(int x) {
  delay(10);
  radio.stopListening();
  delay(10);
  radio.write(&text[x], sizeof(text));
  delay(10);
}


Rx code:
Code: [Select]

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CNS, CE
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    const char text[1];
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}


The problem is if I pass different parameter into my function then the device doesn't send the data to node 2.


example:
Code: [Select]

if (bt == 'F') {
    [b]function(0);[/b]
  }
  if (bt == 'G') {
    [b]function(1);[/b]
  }


Your opinion ?.
7
Hardware / Re: M6E Nano con hardware seri...
Last post by Rakzorg - Today at 05:51 pm
Estuve trabajando con la librería directamente y al parecer es la forma con la que se manejan las variables en e software serial, se requiere cambiar la librería para poder trabajar con el hardware serial pero no lo eh probado con el DUE sino con un PIC32 pero si mucho exito por ahora por problemas con el UART pero no dudo que se pueda implementar en el DUE con los avances que tengo en emular la librería.
8
Software / Re: Problema valori LSM303DLH
Last post by dan303 - Today at 05:50 pm
Ho risolto...ora ho i gradi di inclinazione corretti.


Code: [Select]


#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
  compass.m_min = (LSM303::vector<int16_t>){  -565,   -703,   -560};
  compass.m_max = (LSM303::vector<int16_t>){  +630,   +646,   +616};
}

void loop() {
  
  compass.read();
  int AZ = compass.heading((LSM303::vector<int>){0,1,0});
  Serial.println(String("AZ = ")+AZ+String("°"));

  compass.read();
  float Pi = 3.14159;
  int EL = (atan2(compass.a.y, compass.a.z) *180) / Pi;
  Serial.println(String("EL = ")+EL+String("°"));
  Serial.println("");
  delay(200);
}
9
Français / Re: convertisseur adc 16 bits ...
Last post by aligote - Today at 05:50 pm
Chacun son métier et dans le cas présent faire une carte propre pour mesurer avec les performances demandées est un sacré défi sauf à avoir une bonne expérience en la matière et des moyens humains, techniques et financiers.
.....................................

Je ne connais pas le projet mais pour moi :
- exiger une performance pareille c'est le résultat d'une mauvaise conception du projet.
Il faudrait reprendre le projet à ses débuts pour mieux répartir les contraintes et alléger celle ci.
- ou c'est juste pour détecter avec précision un sens de variation, mais dans ce cas la valeur absolue importe peu.

Il existe des gens dont c'est le métier .......................

Bonjour,

Je souscris complètement.

Serge .D
10
Delta, thanks for your help. I don't lack the ability to put together some sort of workaround to make my program do what I want. I just wondered if there was any way, using pointers or something, for a character (or string) whose value is the same as a variable's name (String myString = "Bapstack", int Bapstack = 12), to refer to that variable's value. Just trying to boost my coding savvy.

Jack, I'm using a Mega for this.
Pages: [1] 2 3 ... 10