Recent Posts

Pages: 1 ... 8 9 [10]
91
Software / Re: [SOLUCIONADO] Salto de fun...
Last post by Swift - Feb 18, 2019, 11:55 pm
Claro que se puede.

Code: [Select]
const byte
ledPin = 3; // the number of the LED pin
char
dato = '3';
bool
estadoLed = LOW,
estadoActivo = 0,
estadoOn = 0;
unsigned long
tiempoActual = 0,
tiempoActivoAnterior = 0,
tiempoAnteriorOff = 0,
tiempoAnteriorOn = 0;
const unsigned int
intervaloActivo = 2000,
intervaloOff = 100,
intervaloOn = 200;

void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT); // Establece al pin del led como salida
}

void loop() {
tiempoActual = millis();
if (Serial.available() > 0) {
dato = Serial.read();
switch (dato)
{
case '3':
Serial.println("Temporizador Activado");
tiempoActivoAnterior = tiempoActual;
estadoActivo = 1;
break;
}
}
switch (dato)
{
case '3':
if (tiempoActual - tiempoActivoAnterior >= intervaloActivo) {
Serial.println("Temporizador Desactivado");
estadoActivo = 0;
}
if (estadoActivo) {
if (!estadoOn) {
if (tiempoActual - tiempoAnteriorOn >= intervaloOff) {
tiempoAnteriorOff = millis();
estadoOn = 1;
estadoLed = HIGH;
Serial.println("Encendido");
}
}
else
{
if (tiempoActual - tiempoAnteriorOff >= intervaloOn) {
tiempoAnteriorOn = millis();
estadoOn = 0;
estadoLed = LOW;
Serial.println("Apagado");
}
}
}
else
{
estadoLed = LOW;
dato = ' ';
}
digitalWrite(ledPin, estadoLed);
break;
}
}
92
Software / Ricavare ultimo carattere di u...
Last post by Marco80 - Feb 18, 2019, 11:54 pm
Salve, mi scuso fin da subito perché mi rendo conto che la domanda è banale ma ho cercato molto prima di arrivare ad aprire un nuovo topic, ovviamente senza esito.
Praticamente dovrei prelevare l'ultimo carattere di una stringa, che può variare di volta in volta in lunghezza.
Oppure andrebbe bene anche prelevare il carattere successivo ad un simbolo specifico (es. / o -).
Che funzioni dovrei usare?
93
Project Guidance / Re: smallest battery that can ...
Last post by ChickenLittle - Feb 18, 2019, 11:52 pm
Thanks to all of you I figured out what battery I am going to use.

Thanks again.
94
Generale / Re: Acquisto Arduino
Last post by gpb01 - Feb 18, 2019, 11:52 pm
Prima di tutto, nella sezione in lingua Inglese si può scrivere SOLO in Inglese ... quindi, per favore, la prossima volta presta più attenzione in quale sezione metti i tuoi post ...

... poi, essendo il tuo primo post, nel rispetto del regolamento della sezione Italiana del forum (… punto 13, primo capoverso), ti chiedo cortesemente di presentarti IN QUESTO THREAD (spiegando bene quali conoscenze hai di elettronica e di programmazione ... possibilmente evitando di scrivere solo una riga di saluto) e di leggere con MOLTA attenzione il su citato REGOLAMENTO ... Grazie.

Guglielmo

P.S.: Il tuo post è già stato spostato nell'opportuna sezione del forum "Italiano"dove puoi proseguire la discussione.

P.P.S.: Ti ricordo che, fino a quando non sarà fatta la presentazione, nessuno ti potrà rispondere, quindi ti consiglio di farla al più presto. ;)
95
Hello all, my name is Stephen and I just bought an arduino kit in hopes of winning the outlaw class for my son's pinewood derby.

So I bought a brushless electric ducted fan (EDF) that will be controlled via an electronic speed controller (ESC) hooked to the Arduino nano. I also plan to attach an accelerometer to the car.

The theory is to activate the EDF for one second or so after the car starts to move down the ramp, once the gates are opened. I want variables for time after motion is first sensed (in case of gate clearance timing/issues) and a variable time for the "on" time for the EDF (so it turns off automatically before it runs off the ramp. I also would like a variable for the speed of the ESC so I can play with the throttle percentage.

Problem is the derby is this weekend and I'm having trouble learning how to code that quickly.

Is there anyway someone could help walk me through the coding to do that?
96
Project Guidance / Re: CDI tester project
Last post by cattledog - Feb 18, 2019, 11:51 pm
Great progress. :-)

I learned a few things from playing around with the simulated response the other day.

1) Depending on the output from the CDI the return pulse interrupt on the tester will need to be either RISING or FALLING. Currently he interrupt pin is set as INPUT_PULLUP and the interrupt FALLING so the pin will respond to a grounding signal from the module. If the module puts out a high pulse, I think the interrupt will need to be changed. The interrupt pin might need an external pull down resistor.

2). When using FALLING mode for the trigger pulse, the time delay of the response pulse needs to be longer the trigger pulse width or else you see strange results as you are getting a negative value from the subtraction of start time from end time.

3).When using first pulse negative, the delayed response simulator needs to see a pulse from pin 8 and not pin 9. 

4) When the charge pulses are active, I see some additional delay (approx 30us) at 0 delay which I don't understand. The charge pulses should not be interactive with the trigger pulse or the return pulse interrupt but I see something. At longer delays, the effect seems reduced. I would keep my eye on the AC mode.

Good luck going forward. Please report back with how this project turns out.


97
It is likely to be a standard taper. Machine tools which use tapers might be sold as "2MT" or "3MT" which gives a specific size within a specific system of tapers. (The Morse taper, in this example.)

Look for "gears for tapered shaft" and I'm sure you'll quickly find what the different tapers are called. Then you can look up the standard to find out which one you have.
98
Project Guidance / Re: 4 x 4 RGB LED grid?
Last post by GoForSmoke - Feb 18, 2019, 11:49 pm
Using a matrix will make this project harder, much harder and looking more amateur at best. You are already pulsing leds one at a time in a matrix, PWM won't help with that.

While pulsing leds you expect to read joystick axes? Please forget the bleeding matrix!

99
Programming Questions / Problem reading using Serial.r...
Last post by ZentriXG - Feb 18, 2019, 11:47 pm
I have tried this code, that is supposed to take user input ("on" or "off") and turn an LED on or off, as the input requests. This code helped me only to turn on the LED, but the OFF "command" does not work. I've tried a lot of other methods, which didn't work. Feel free to ask me anything and send me some of your suggestions, please!

Code: [Select]

// the setup function runs once when you press reset or power the board
int fade = 11;

void setup() {
  pinMode(fade, OUTPUT);
  Serial.begin(9600);
  Serial.println("Input n for on. Input f for off");
}

char inChar;
char inData[4];
int index = 0;

void loop()
{
  while(Serial.available() > 0){ // Don't read unless there you know there is data
      if(index < 3) // One less than the size of the array
      {
          inChar = Serial.read(); // Read a character
          inData[index] = inChar; // Store it
          index++; // Increment where to write next
          inData[index] = '\0'; // Null terminate the string
      }
  }

  if(strcmp(inData, "on") == 0){
    digitalWrite(fade, HIGH);
  }else if(strcmp(inData, "off") == 0){
    digitalWrite(fade, LOW);
  }//else Serial.println(inData);
 
}
100
Sensors / Re: HC-SR04 - storing the dist...
Last post by joodaa - Feb 18, 2019, 11:46 pm
google esp8266 spiffs write file



Most likely (your data) <<<<<< (SPIFFS file system size), but only you would know for sure.

Thank you, I found a code for SPIFFS below, and I think it writes instead of just reading, how would I merge this with the ultrasonic sensor code, to then store the data?

Code: [Select]
#include <ESP8266WiFi.h>
#include <FS.h>   //Include File System Headers
 
const char* filename = "/samplefile.txt";
 
  
void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
 
  //Initialize File System
  if(SPIFFS.begin())
  {
    Serial.println("SPIFFS Initialize....ok");
  }
  else
  {
    Serial.println("SPIFFS Initialization...failed");
  }
 
  //Format File System
  if(SPIFFS.format())
  {
    Serial.println("File System Formated");
  }
  else
  {
    Serial.println("File System Formatting Error");
  }
 
  //Create New File And Write Data to It
  //w=Write Open file for writing
  File f = SPIFFS.open(filename, "w");
  
  if (!f) {
    Serial.println("file open failed");
  }
  else
  {
      //Write data to file
      Serial.println("Writing Data to File");
      f.print("This is sample data which is written in file");
      f.close();  //Close file
  }
 
}
void loop() {
  int i;
  
  //Read File data
  File f = SPIFFS.open(filename, "r");
  
  if (!f) {
    Serial.println("file open failed");
  }
  else
  {
      Serial.println("Reading Data from File:");
      //Data from file
      for(i=0;i<f.size();i++) //Read upto complete file size
      {
        Serial.print((char)f.read());
      }
      f.close();  //Close file
      Serial.println("File Closed");
  }
  delay(5000);
}


Pages: 1 ... 8 9 [10]