Recent Posts

Pages: [1] 2 3 ... 10
1
how do i upload a code to my arduino uno R3?
why cannot i do so in in the 1.8.0 version
2
Deutsch / Re: Relais mit Taster steuern
Last post by agmue - Today at 07:41 am
Es eilt übrigens nicht. Ich habe Zeit!!
Beste Voraussetzungen!

Danke für die Rückmeldung :)
3
The button works but it doesn't update value of the button when the animation is running.  
Obviously! your animations are full of delays.


How can I have the button value constantly update while the animation is running?
In your case using an interrupt to register your button presses might be easier OR you could try implementing several things at the same time
4
Hello,

I am fairly new to Arduino and am currently working on a research project for which I will be measuring pressure in two environments. The sensor I am working with is an Adafruit MPRLS pressure sensor on a Sparkfun Redboard.  My question is how to have the two sensors run at the same time over the course of several hours.  I have stared understanding that I will more than likely need to change the address of one of the sensors, but these sensors have permanent addresses.  If anyone can help in this I would appreciate it. I have included my code for one sensor and the library for that sensor.

-Thanks

https://github.com/adafruit/Adafruit_MPRLS/blob/master/Adafruit_MPRLS.h

Code: [Select]

#include <Wire.h>
#include "Adafruit_MPRLS.h"

#define RESET_PIN  -1
#define EOC_PIN    -1
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);

void setup() {
  Serial.begin(9600);
  Serial.println("Time \tPSI");
  mpr.begin();
}

void loop() {
  int timeStamp = millis()/1000;
  float pressure_hPa = mpr.readPressure();
  if(pressure_hPa < 0.0001) pressure_hPa = 0;
  Serial.print(timeStamp); Serial.print("\t");
  Serial.print(pressure_hPa); Serial.println();
  delay(250);
}
5
Project Guidance / Re: nRF24L01 and ESP8266 in Ar...
Last post by v_o_i_d - Today at 07:34 am
Could it be the issue that the esp8266 is not deriving required power from the 3.3v arduino pin after nRF24 gets connected! Just curious. Since I didnt make use of a resistive divider or regulator during supply
6
Software / Re: Mi serve un consiglio per ...
Last post by torn24 - Today at 07:27 am
Ciao! Non vedere tutto negativo perché non è cosi :) Questo forum è un ambiente dove si aiuta volentieri, è formato da tanti utenti che non sono specializzati ne in elettronica ne in informatica, è un forum aperto a tutti molto tollerante.
La presentazione non deve essere un curriculum, ma solo due righe per sapere quanto sei preparato di elettronica e in programmazione. E' utile per chi deve rispondere, ad esempio a me è capitato di voler rispondere a qualche domanda sulla programmazione, ma leggendo la presentazione ho scoperto che erano programmatori professionisti, ho evitato quindi di dare risposte da "principiante" a qualcuno che è laureato in informatica, perché certamente ne sapeva più di me :)
7
I want to have a button switch the animation that is running. The button works but it doesn't update value of the button when the animation is running. How can I have the button value constantly update while the animation is running? here is my code:
Code: [Select]

#include <FastLED.h>

#include "Plasma.cpp"
#include "TestPattern.cpp"
#include "Snake.cpp"
#include "Twinkle.cpp"
#include "DeadChannel.cpp"
#include "Bouncy.cpp"
#include "HiRez.cpp"
#include "Boxes.cpp"
#include "Life.cpp"
#include "Sprite.cpp"

#define WIDTH 14
#define HEIGHT 14
#define NUM_LEDS WIDTH * HEIGHT

#define DATA_PIN 3

CRGB leds[NUM_LEDS];
const int  buttonPin = 5;   

// Variables will change:
int buttonPushCounter = 0;   
int buttonState = 0;
int lastButtonState=0;       
 

void setup() {
  // put your setup code here, to run once:
pinMode(buttonPin, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(8, OUTPUT);


    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
    Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
//    TestPattern testPattern(leds, WIDTH, HEIGHT);
//    testPatt.start();

 buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
     
    }
   
  }
 
  lastButtonState = buttonState;

  if (buttonPushCounter  == 1) {


digitalWrite(8,HIGH);
doTwinkle();

   
   
  } else if (buttonPushCounter  == 2){
   

digitalWrite(9,HIGH);
doSnake();

     
  } else if (buttonPushCounter  == 3){


digitalWrite(10,HIGH);

doPlasma();
   
    buttonPushCounter = 1;
  }
   
   
   
   
}

void doDeadChannel() {
    DeadChannel deadChannel(leds, WIDTH, HEIGHT);
    deadChannel.start();
}

void doPlasma() {
    Plasma plasma(leds, WIDTH, HEIGHT);
    plasma.start();
}

void doTwinkle() {
    Twinkle twinkle(leds, WIDTH, HEIGHT, true, true);
    twinkle.start();
}

void doSnake() {
    Snake snake(leds, WIDTH, HEIGHT);
    snake.start();
}

void doLife() {
    Life life(leds, WIDTH, HEIGHT, 56);
    life.start();
}

void doSprite() {
    Sprite sprite(leds, WIDTH, HEIGHT);
    sprite.start();
}


Thats the main part here is the parts that it refers to

Twinkle:

Code: [Select]
/*
 * Effect implementation for the GauntletII project.
 */

#include "Effect.h"


#define MAX_TWINKS 25
#define OFFSET 0xB000

typedef struct Twink {
    short x;
    short y;
} Twink;

class Twinkle : public Effect {
   
private:
    short numTwinks;
    bool colour;
    bool cycleSaturation;
   
public:
    Twinkle(CRGB *leds, int width, int height, bool colour, bool cycleSaturation) :
        Effect(leds, width, height),
        colour(colour),
        cycleSaturation(cycleSaturation),
        numTwinks(0) {
    }
   
    void start() {
        for (uint16_t frame = 0x0000, iterations = 0; iterations < 2250; frame += 0x20, iterations++) {
            for (int i = 0; i < width * height; i++) {
             
                if (leds[i]) {
                    leds[i].fadeToBlackBy(50);
                    if (!leds[i]) {
                        numTwinks--;
                    }
                } else {
                    if (random(56) == 0) {
                        numTwinks++;
                        if (colour) {
                            if (cycleSaturation) {
                                uint8_t saturation = (sin16(frame + OFFSET) >> 8) + 128;
                                leds[i] = CHSV(random(255), saturation, 255);
                            } else {
                                leds[i] = CHSV(random(255), random(128, 255), 255);
                            }
                        } else {
                            leds[i] = CRGB::White;
                        }
                    }
                }
            }
            LEDS.show();
        }
    }
};


Snake:

Code: [Select]
/*
 * Effect implementation for the GauntletII project.
 */

#include "Effect.h"

class Snake : public Effect {
private:
   
    static const byte SNAKE_LENGTH = 16;
   
    enum Direction {
        UP, DOWN, LEFT, RIGHT
    };
   
    struct Pixel {
        uint8_t x;
        uint8_t y;
    };
   
    CRGB colours[SNAKE_LENGTH];
    uint8_t initialHue;
   
    Pixel pixels[SNAKE_LENGTH];
   
    Direction direction;
   
    void newDirection() {
        switch (direction) {
            case UP:
            case DOWN:
                direction = random(0, 2) == 1 ? RIGHT : LEFT;
                break;
               
            case LEFT:
            case RIGHT:
                direction = random(0, 2) == 1 ? DOWN : UP;
               
            default:
                break;
        }
    }
   
    void shuffleDown() {
        for (byte i = SNAKE_LENGTH - 1; i > 0; i--) {
            pixels[i] = pixels[i - 1];
        }
    }
   
public:
    Snake(CRGB *leds, int width, int height) : Effect(leds, width, height), initialHue(0) {
        direction = UP;
        for (int i = 0; i < SNAKE_LENGTH; i++) {
            pixels[i].x = 0;
            pixels[i].y = 0;
        }
    }
   
    void start() {
        clearLeds();
        for (int frameNo = 0; frameNo < 1000; frameNo++) {
            shuffleDown();
            if (random(10) > 6) {
                newDirection();
            }
            switch (direction) {
                case UP:
                    pixels[0].y = (pixels[0].y + 1) % height;
                    break;
                case LEFT:
                    pixels[0].x = (pixels[0].x + 1) % width;
                    break;
                case DOWN:
                    pixels[0].y = pixels[0].y == 0 ? height - 1 : pixels[0].y - 1;
                    break;
                case RIGHT:
                    pixels[0].x = pixels[0].x == 0 ? width - 1 : pixels[0].x - 1;
                    break;
            }
            fill_rainbow(colours, SNAKE_LENGTH, initialHue++);
            for (byte i = 0; i < SNAKE_LENGTH; i++) {
                pixel(pixels[i].x, pixels[i].y) = colours[i] %= (255 - i * (255 / SNAKE_LENGTH));
            }
            LEDS.show();
            delay(30);
            clearLeds();
        }
    }
};




8
Microcontrollers / Re: Atmega328P doesn't start o...
Last post by BJHenry - Today at 07:16 am
The best thing you can do is to embed a picture of the schematic in your OP- making people visit an external site is a bit of a pain. I've attached it here to make things easier.

You're missing the 0.1uF decoupling caps for the microcontroller.

9
Hint: You can't declare functions inside other functions.
10
Hello,

Does anyone know how one can pass a parameter when using the WebServer.h's function "server.on()" so it could do something like this:

Code: [Select]
server.on("/string", function(parameter))   

?

Thank you,

Pages: [1] 2 3 ... 10