HI EVERYONE ?
I HOPE ALL BE FINE.
I'M PLEASURE BECAUSE THIS IS MY FIRST SUJIT IN THIS FORUM ; AND I HOP FIND WHAT I WANT ,I WAS TRY TO DEVELOP THIS PROGRAMME FROME MANY PROGRAMS FOUND IN YOUTUBE ;
AND AS DON'T KNOW; I'M JUST AN ARDUINO HOBBIES;
IM TEACHER IN ELECTRICITY AND I'M NOT A PROGRAMER
THIS IS MY FIRST STEPS TO PROGRAMMATION;
I THINK IT'S NOT WORKING WILL;
THIS A JUST IMAGE TO APPROXIMATION OF IDEA , BECAUSE I HAVE ALL REAL HARDWARE;
ARDUINO MEGA - 200*(TTP223) - 25*(74HC165) - 3 STREEP LED 144 (WS2815) .
MY PROBLEM IS :
I NEED A FAST RESPONDING TO TOUCH BOTTOM, AND HOW CAN I DO :
1 - DO A SHADOW PIXEL ANIMATIONS .
2 - CHANGE PIXEL COLORS.
3 - AND ACTIVATE TOGGLE FUNCTION FROM PROGRAMING ( NOT THE TTP223 TOGGLE)
IF A SWITCH HIGH OR LOW ,
#include "FastLED.h"
#define NUM_LEDS 8
#define PIN_LED 8
#define LED_COLOR CRGB::DarkOrchid
CRGB rgb_led[NUM_LEDS];
int ioSelect = 2; // SH/LD 1.
int clockPulse = 3; // CLK 2.
int dataOut = 4; // QOUT 9.
int num_leds_switchedon=0;
byte switchVar = 0;
int j; //used in a for loop to declare which bit is set to 1
int value; //stores the digital read value of the data pin
//(0 if no button is pressed, 1 if a button is pressed)
void setup() {
pinMode(ioSelect, OUTPUT);
pinMode(clockPulse, OUTPUT);
pinMode(dataOut, INPUT);
Serial.begin(9600); //setting baud rate
FastLED.addLeds<WS2812B, PIN_LED>(rgb_led, NUM_LEDS);
FastLED.setBrightness(255);
rgb_led[NUM_LEDS] = CRGB::Black;
FastLED.show();
}
int8_t gHue = 0;
void loop() {
byte dataIn = 0;
// uint16_t dataIn = 0; //Swap out byte for uint16_t or uint32_t
digitalWrite(ioSelect, 0); // enables parallel inputs
digitalWrite(clockPulse, 0); // start clock pin low
digitalWrite(clockPulse, 1); // set clock pin high, data loaded into SR
digitalWrite(ioSelect, 1); // disable parallel inputs and enable serial output
//////////////////////////////////
for (j = 0; j < 8; j++) { //sets integer to values 0 through 7 for all 8 bits
value = digitalRead(dataOut); //reads data from SR serial data out pin
if (value) {
int a = (1 << j); // shifts bit to its proper place in sequence.
/*for more information see Arduino "BitShift" */
dataIn = dataIn | a; //combines data from shifted bits to form a single 8-bit number
/*for more information see Arduino "Bitwise operators" */
num_leds_switchedon = map(j, 0, 8, 0, NUM_LEDS);
rgb_led[num_leds_switchedon] =CRGB::DarkOrchid ;
// rgb_led[num_leds_switchedon] += CHSV(random8(64), 20, 255); NOT WORKING
FastLED.show();
// leds[pos] += CHSV( gHue, 255, 192); NOOOOO
}
rgb_led[num_leds_switchedon] = CRGB::Black;
FastLED.show();
digitalWrite(clockPulse, LOW); //after each bit is logged,
digitalWrite(clockPulse, HIGH); //pulses clock to get next bit
}
}
THIS IS THE FIRST CODE BUT THE RESULT IN DECIMAL NOT BINARY
#include "FastLED.h"
#define NUM_LEDS 255
#define PIN_LED 8
#define LED_COLOR CRGB::DarkOrchid
CRGB rgb_led[NUM_LEDS];
int ioSelect = 2; // SR Pin 15.
int clockPulse = 3; //SR Pin 7.
int dataOut = 4; //SR Pin 13.
int j; //used in a for loop to declare which bit is set to 1
int value; //stores the digital read value of the data pin
//(0 if no button is pressed, 1 if a button is pressed)
byte switchVar = 0; //stores a byte array to show which button was pressed
void setup() {
pinMode(ioSelect, OUTPUT);
pinMode(clockPulse, OUTPUT);
pinMode(dataOut, INPUT);
Serial.begin(9600); //setting baud rate
FastLED.addLeds<WS2812B, PIN_LED>(rgb_led, NUM_LEDS);
FastLED.setBrightness(100);
}
void loop() {
byte dataIn = 0;
// uint16_t dataIn = 0; //Swap out byte for uint16_t or uint32_t
digitalWrite(ioSelect, 0); // enables parallel inputs
digitalWrite(clockPulse, 0); // start clock pin low
digitalWrite(clockPulse, 1); // set clock pin high, data loaded into SR
digitalWrite(ioSelect, 1); // disable parallel inputs and enable serial output
for(j = 0; j < 8; j++) { //sets integer to values 0 through 7 for all 8 bits
value = digitalRead(dataOut); //reads data from SR serial data out pin
Serial.print("Button Position: "); // checks bit position 0-7
Serial.println(j);
Serial.print("Button Value: "); //checks whether button was pressed (high vs low)
Serial.println(value);
}
int num_leds_switchedon = map(value,0, 255, 0,NUM_LEDS);
for (int i = 0; i < num_leds_switchedon; ++i) {
rgb_led[i] = LED_COLOR;
}
for (int i = num_leds_switchedon; i < NUM_LEDS; ++i) {
rgb_led[i] = CRGB::Black;
}
FastLED.show();
}
THANK YOU FRIENDS