Recent Posts

Pages: [1] 2 3 ... 10
1
I've attached a "GOOD" picture of the wiring below. Note that Pins 7 and 8 are the pushbutton pins when shorted to ground.

Here's the code so far:

Code: [Select]

int brightness = 10;

//const byte LED       = 11;
//const byte maximum   = 10;
//const byte decrement = 8;
//const byte increment = 9;

const byte LED       = 3;
const byte maximum   = 4;
const byte decrement = 7;
const byte increment = 8;

void setup()
{
  pinMode(LED, OUTPUT);             // Set pin 3 to be in output mode
  pinMode(decrement, INPUT_PULLUP); // Set pin 7 to be in input mode
  pinMode(increment, INPUT_PULLUP); // Set pin 8 to be in input mode
  pinMode(maximum, INPUT_PULLUP);
}

void loop()
{
  if (digitalRead(decrement) == LOW)
  {
    brightness--;                  // If button on pin 7 is pressed, reduce brightness
  }

  if (brightness < 0)
  {
    brightness = 0;                // Don't let brightness drop below zero
  }

  if (digitalRead(increment) == LOW)
  {
    brightness++;                  // If button on pin 8 is pressed, increase brightness
  }

  if (brightness > 255)
  {
    brightness = 255;              // Don't let brightness get above 255
  }

  if (digitalRead(maximum) == HIGH)       //if pin 4 is HIGH
  {
    analogWrite(LED, brightness); // Set pin 3 to the new brightness level
  }
  else
  {
    analogWrite(LED, 0);          //else turn it off
  }

  delay(10);                      // Wait a short time, just to slow things down a little
}
2
Deutsch / Re: zwei Wert auf ThingSpeak ü...
Last post by michael_x - Today at 12:00 pm
Vielleicht wollte mann03 ja auf was ganz anderes antworten,  ich sehe nämlich keinen sinnvollen Zusammenhang...
3
Deutsch / Re: C-Dateien in die Arduino-I...
Last post by mega-hz - Today at 11:59 am
ist also nicht so kompatibel zur Arduino IDE?

Besser Visual Studio oder Atmel Studio installieren?
4
Hi guys, I tweaked the code a bit and realised that the morseBtn sequence is recorded only when the modeBtn is kept pressed. Can you help me change this code a bit to make sure the Arduino gets ready to record the morseBtn sequence as soon as the first button is pressed once and released ? I've attached the code below :

byte morseBtn = 6;
byte modeBtn = 4;
byte led = 9;

boolean inRecordMode = false;
boolean wasInRecordMode = false;

int maxSamples = 100;
boolean states[100];
int durations[100];

int idxPlayback = 0;
int idxRecord = 0;
int sampleLength = 1; // 1 ms


void setup() {
  //Serial.begin(9600); 
  pinMode(modeBtn, INPUT);
  pinMode(morseBtn, INPUT);
  pinMode(led, OUTPUT);
}

void loop() {
  inRecordMode = digitalRead(modeBtn);
  if(inRecordMode == true) {
    if(!wasInRecordMode) {
      // reset record buffers
      memset(states, 0, sizeof(states));
      memset(durations, 0, sizeof(durations));
      idxRecord = 0; // reset record idx just to make playback start point obvious
    }
    recordLoop();
  } else {
    playbackLoop();
  }
 
  wasInRecordMode = inRecordMode; // record prev state for next iteration so we know whether to reset the record arr index
}

void recordLoop() {
  boolean state = digitalRead(morseBtn);
  digitalWrite(led, state); // give feedback to person recording the loop
 
  if(states[idxRecord] == state) {
    // state not changed, add to duration of current state
    durations[idxRecord] += sampleLength;
  } else {
    // state changed, go to next idx and set default duration
    idxRecord++;
    if(idxRecord == maxSamples) { idxRecord = 0; } // reset idx if max array size reached
    states[idxRecord] = state;
    durations[idxRecord] = sampleLength;
  }
 
  delay(sampleLength); // slow the loop to a time constant so we can reproduce the timelyness of the recording
}

void playbackLoop()
{
  // play the loop back at the desired speed
  digitalWrite(led, states[idxPlayback]); // set led
  delay(durations[idxPlayback]  // leave led in that state for duration
 
  idxPlayback++;
  if(idxPlayback == maxSamples) { idxPlayback=0; } // repeat the recorded loop
}
5
Software / Re: Progetto comunicazione ard...
Last post by gpb01 - Today at 11:57 am
Mi raccomando quanto al mio post#1

Guglielmo
6
WE have a solution for some nano !!


in fact , the boatloader is the BL of a Micro , so our NANO is reconize as Micro and works as Micro ...

Thanks to Simon and Benoit !

Have a good day !
7
Quote
Hi,
What voltage do you measure on the 5V pin of the LM35 with the battery in use and then the USB in use?


I hope -12V is really gnd?
lol, yip all is as in pic's I know things look wrong, but the ribbon cable is the only male to female jumpers that I have  ;D
it looks kind of neat to  :smiley-roll:

I will test that as soon as I can.

but before I take us down that road...
I did a quick test...
I plugged it into a USB charger, and nothing.
commented out all 'DigiKeyboard', and then it worked.
so it would seem like "DigiKeyboard.h" is the culprit (it's looks for a USB connection before it would run)
I will assume that everything will be powered by the Vin which would be higher than the USB voltage.

at this point, it would seem like the DigiKeyboard.h will have to be edited, or no library must be used, and I have to use a very striped down version of its code in my sketch,
feeling a bit worried now  :smiley-confuse:
8
Deutsch / Re: C-Dateien in die Arduino-I...
Last post by michael_x - Today at 11:53 am
Quote
error: invalid conversion from 'unsigned int (*)()' to 'unsigned int (*)(button*)' [-fpermissive]
Der erste Fehler sagt schonmal, dass eine Funktion ohne Parameter was anderes ist als eine mit einem button* .
Der nächste Fehler ist was anderes.

Nun kannst du zwar C - Funktionen verwenden, hast aber immer noch viel zu tun.
;)
9
General Electronics / Re: Power supply auto switch
Last post by spleen - Today at 11:53 am
Thanks Septillion,

The idea is it will never be powered without an external supply. I was more worried abut how to isolate the VUSB when i plug it in for programming. So long as the diode is fine i'll run with that.

Still, that's a good idea. I'll monitor the 12V input through a voltage divider for full load. There will be plenty of spare pins on the mcu.

Thanks
10
Project Guidance / Re: Infared remote control
Last post by ugniusugnis - Today at 11:51 am
With this code I try and this code I see in video.

P.S. I forgot send link to video: https://www.youtube.com/watch?v=zLR8EevE5_A (firs code)

Code: [Select]

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    irrecv.resume(); // Receive the next value
  }
}
Pages: [1] 2 3 ... 10