Recent Posts

Pages: 1 ... 8 9 [10]
91
Taking a hint from johnwasser  I shifted the .h and .ino header files into the same folder as GHTS.ino.  When I woke up to what the compiler error messages meant I removed the void setup() and void loop() code from each of those files and all compiled well.  It appears to link - well, at least the compiler has found the files.

Here comes the hard bit:  :smiley-eek-blue:

I actually want two sketches, one to run a stationary console and the other to run a mobile vehicle.  Communication between the two is to be using the nRF24L01 PCB.  I created the sketches in the GHTS folder and named them GHTS_Console.ino and GHTS_Trolley.ino.  Now the Arduino IDE insists that each be in its own folder, and that necessitates two copies of the .h  and .ino header files.  From my programming experience, that is a recipe for disaster.  Configuration Management becomes a nightmare if you start doing things like that.

Now, robin2 suggested a work-around for that by addressing these files in the #include statement.  If I can get that to work then I can have just the one copy of each with both of them accessible to my two sketches.. Once again, however,
Code: [Select]
#include ".\..\GHTS_Private.h\GHTS_Private.h"
gets spat out by the compiler.

What is the key to addressing the files in the #include statement?
92
Robotics / Re: drive 4 stepper motors wit...
Last post by jremington - Today at 12:47 am
Yes, the Arduino can easily read 0-5V signals with the ADC, which translates the voltages into values ranging from 0 to 1023.

Based on those values, your program can then make decisions about how to move the steppers.

There are many simple examples included with the Arduino software that will teach you to use the ADC, make decisions, etc. Many other tutorials on this forum and elsewhere teach about how to use stepping motors, etc.

Finally, to run four stepping motors will require four motor drivers and a substantial power supply. Don't try to power any motors from the Arduino directly.

Sounds like a fun project!
93
OK! Thank for your advices! It works! The key was to redefine "state" variable after changing the relay pin state. I'm pasting the solution - maybe I'll help someone:

Code: [Select]

/*
   created by Rui Santos, http://randomnerdtutorials.com
   Bluetooth App - Turn On and Off LED
*/

int relay_pin = 13;
int state;
#define button A3

void setup() {
  pinMode(button, INPUT_PULLUP);
  pinMode(relay_pin, OUTPUT);
  Serial.begin(115200);
  state = '2'; // relay is OFF after switch on the device
}

void loop() {
  // bluetooth as switch
  if (Serial.available() > 0)
  {
    state = Serial.read();
  }

  if (state == '1')
  {
    digitalWrite(relay_pin, LOW);
  }

  else if (state == '2')
  {
    digitalWrite(relay_pin, HIGH);
  }
  delay(100);
  Serial.println(state);


  // button as switch
  if (digitalRead(button) == LOW)
  {
    delay(350);
    if (state == '1')
    {
      digitalWrite(relay_pin, HIGH);
      state = '2';
    }
    else if (state == '2')
    {
      digitalWrite(relay_pin, LOW);
      state = '1';
    }

    while (digitalRead(button) == LOW);
    delay(100);
  }

}

94
Project Guidance / Re: ESP8266
Last post by PieterP - Today at 12:46 am
This is how I wire my ESP8266's:
95
The major car manufacturers spend many many man-years of testing and measuring to produce such
software.  And of course they compromise between performance and efficiency - and sometimes they
cheat ( see the recent VW debacle..)

  It's not easy

regards

Allan
Please focus on the project! I know how to tune cars,i do tune how should be done in a dyno with a calibrated wideband senson and a calibrated knock moniror,and then same on the road. i have more than a decade of tuning cars experience
I tune
Microtech
Megasquirt
Haltech
Adaptronic
Apex-i fc comander
Apex-i safc
Perfect power smt6,smt8,smt8L
I have expierence flashing mitsubishi ecu
I dont want to be rude or arrogant
I know how to tune cars please dont keep telling its dificult,ist imposible, i will break engine, maybe you someone that does not know it is will be dificult,for me is no.
What i dont know and i need help is  making the code there im a cero
96
That's it.
Does anyone know how to reset it so to appear on the primary monitor without
having to reconnect the secondary monitor...
 Funny this thing appears still at version 1.6.11

My software is at version 0.0 and i have fixed this issue... lol
97
Software / Re: Escribir nombre archivo se...
Last post by Lucario448 - Today at 12:45 am
Y que tal si antes de hacer el seek, hacer un flush?

Llamar a flush o a close garantiza que los datos sean físicamente escritos en la tarjeta SD.

El principio de la función lap_w deberia quedar así:

Code: [Select]
void lap_w(){
  Serial.println(myFile.size());
  // Si no se añadieron mas vueltas y el archivo acaba en la segunda, entonces el valor esperado es 134, 136 o 138
  // A este valor se le debería sumar 9 cada vez que se llame esta función.

  myfile.flush();
  Serial.println(myFile.size());
  // Si solo sobrescribe y no introduce nada nuevo, los valores esperados deberían ser los mismos: 134, 136 o 138
  // A este valor se le debería sumar 9 cada vez que se llame esta función.
  myFile.seek(myFile.size() - 1);
  Serial.println(myFile.position()); // Valor esperado: 104
  Serial.println(tiempo_actual);

Qué aparece en el monitor serie al intentar visualizar esos valores?
98
Bar Sport / Re: opinions on death .
Last post by Henry_Best - Today at 12:45 am
i respect your opinion .
but can you justify , the logical intuitive pattern that led you to believe that consciousness fades away after death ?
Where did I claim I believe that it fades away after death?
I wish people would stop putting words in my mouth that I didn't say.

Consciousness is a function of brain activity. At death, all brain activity stops.
Zero brain activity is the medical definition of death.
So consciousness disappears at death (and, sometimes, before death).
99
Software / Re: Problema al mandar imágene...
Last post by Skedrol - Today at 12:44 am
Gracias betomax, le echaré un ojo.
100
Here is a version of your slave which removes the serial printing from the interrupt. It reads a one byte command and sends a one byte echo response. There is some error testing on the number of bytes received from the master.

We have asked several times for what the master side is doing. How many bytes is it sending, and how many bytes does it request back. You really need to know that information.If it is requesting more than one byte, you need to send a multi byte buffer from the slave, and not perform multiple wire.write commands of a single byte.

I've included a Master sketch which sends one byte and requests one byte back. 

Both Master and Slave sketch are in sync.

SLAVE
Code: [Select]
#include <Wire.h>
#define SLAVE_ADDRESS 0x0B
//volatile byte command = 0x00;
volatile char command;

volatile boolean newCommandReceived = false;
volatile boolean newEchoSent = false;
volatile boolean errorBytesReceived = false;
byte errorBytes;

void setup() {
  Serial.begin(9600);
  Wire.begin(SLAVE_ADDRESS);
 
  Wire.onReceive(receiveData);
  Wire.onRequest(sendData);
 
}

void loop() {
 
  if (newCommandReceived == true)
  {
    Serial.print("received data from master:");
    Serial.println(command);
    newCommandReceived = false;
  }

  if (errorBytesReceived == true)
  {
    Serial.println("Unexpected number of bytes = ");
    Serial.println(errorBytes);
    errorBytesReceived = false;
  }
 
  if (newEchoSent == true)
  {
    Serial.print("data sent to master:");
    Serial.println(command);
    Serial.println();
    newEchoSent = false;
  }
}

void receiveData(int numBytes) {
  if (numBytes == 1)
  {
    command = Wire.read();
    newCommandReceived = true;
  }
  else
  {
    errorBytesReceived = true;
    errorBytes = numBytes;
  }
}

void sendData() {
  Wire.write(command);
  newEchoSent = true; 
}


MASTER

Code: [Select]

#include <Wire.h>
char command[3] = {'a', 'd', 'e'};
#define SLAVE_ADDRESS 0x0B

void setup() {
  Wire.begin();       
  Serial.begin(9600); 
  Serial.println("MASTER");
}

void loop() {

  for (int i = 0; i < 3; i++)
  {
    Serial.print("Send command ");
    Serial.println(command[i]);
    Wire.beginTransmission(SLAVE_ADDRESS);
    Wire.write(command[i]);
    Wire.endTransmission();
   
    Wire.requestFrom(SLAVE_ADDRESS, 1);   
      char c = Wire.read();
      Serial.print("Receive echo back ");
      Serial.println(c);         
      Serial.println();
      delay(1000);
  }
}
Pages: 1 ... 8 9 [10]

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy