text:
How to connect an L293D and an MPU6050 to run together?
I'm wondering how to connect the L293D (H-bridge) and an MPU 6050.
I'm using 1 Arduino Uno, 2 DC motors, 1 MPU6050 and an L293D.
When I tried this, I got some sparks/smoke from the breadboard and none of the motors where running. I only used a 9v battery, not 12v.

Here's the L293D:

MPU 6050 wiring: int-digital 2, SDA-A4, SCL-A5, GND-GND, VDD-Vss
L293D wiring: Vss-VDD, Input4-Digital 5, Output4-Motor, Output3-Motor, Input3-Digital 6, Enable2-5V, Enable1-5V, Input1-Digital 9, Output1-motor, Output2-motor, Input2-Digital 10, Vs-12V battery.

I can't see the connections on that Fritzing diagram clearly enough to answer.  A properly-drawn schematic might help.  Also, if you only used a 9V battery, draw the diagram and schematic that way, instead of drawing 9V in series with 3V and then saying differently.  Also indicate how you are powering the Arduino -- is it via USB?  The diagram doesn't show anything connected to Vin.  Also indicate pin 1 on the L293D

You should not be using a 9v "transistor" battery in a motor control project.  This 9v + 2xAA horrible idea keeps showing up in posts, so clearly some grossly misguided person is promoting that somewhere on the Internet, but it is a flawed idea best avoided.  If you really need such a voltage, use 8-10 AA's to have decent current capability.  The L293D and L298 are also general bad ideas, requiring relatively high voltages to overcome their loss, while many of the readily available motors/gearboxes want low voltages and high current more suited to FET driver chips.

I agree with @ChrisStratton. That is not a 12V battery.

It actually is a 12v (nominal) battery, it is just not suitable for the task.

I don't really se anything wrong with the wiring, atleast your diagram seems to be in order. only thing I would ad is give the pin 8 a ceramic capacitor to ground
but There is a few possible issues you can check.
1 -the sparks make me think that you had a Loose connection at the spark site on the breadboard, maybe the IC was not properly pushed Down in the breadboard, this happens alot, try Again and make sure the IC is complete inserted.
2 - if this does not work You might have destroyed the first L293 or the breadboard tracks but if you have more than one try to see if a replacement or movement of the old ic does the trick
3 -  the motors are to large, and so the current drawn is to high for the L293 to handle and caused thermal shutdown of the L293, a very high current drain will also occur if the motor is stalled. Anyway add some current limiting resistors and see what happends.
4 - if the motor hums without moving then it is because Both the forward and reverse input eg. 1 and 2 is enabled simultaneously.
5 - the code is not appended, so that cannot be verfified, but the MPU 6050 is correctly installed

Ive switched out the H-bridge and added a capacitor. But still nothing

There a some mistakes with the wiring of the supply voltage (Vss) according to the datasheet (http://www.ti.com/lit/ds/symlink/l293.pdf) of the L293D a those on pin 8 (Vss2) and 16 (Vss1). I think those are not connected because each Vss is for one motor of the driver. So you have to connect 9V (or 12V) to both pins.
There is also something wrong with the capacitor (polarity). And your connection of the battery to the breadboard is a bit weird because + of the battery is usally the red not the black wire / marked row on the breadboard.

I will add the changes when i get time. For any people in the future

Hey do you mean that i should connect pin 16 to the battery and not the arduino 5V?

VCC1 16 — 5-V supply for internal logic translation
VCC2 8 — Power VCC for drivers 4.5 V to 36 V


text:
What is the necessity of "Prototyping Shield" for an arduino UNO R3?
I just want to learn Arduino and make some  small projects. But in  the beginner starter kit there's  a part named Prototyping Shield. Is it necessary or will it help me?

The official starter kit has no "Prototyping Shield" (but a breaboard).

In general, there's no need for a prototyping shield; a simple breadboard and wires will do. The only advantage is (from my viewpoint) that it is easier to bring along with you on holiday if you want to perform some experiments... That's the only way I use it.

A prototyping shield allows you to create your own circuit that can sit neatly on top of an Arduino.  Its main advantage is the pins/holes to connect to the Arduino, as these aren't evenly spaced so they are difficult to replicate with strip-board.
Do you need one? I doubt it very much, stick to the bread board and leave the soldering iron alone until you know what you are doing.

Also this would have been better in the Arduino StackExchange forum, pop on over some time.

You can make a slightly neater project with a prototyping shield. You can use much shorter jumper wires are sufficient to connect to the Arduino pins than if the proto was on your bench beside the Uno. That makes the project much more easily portable without knocking wires out of place. And if the project is one you want to make permanent, you've already laid it out for a shield and you're pretty near ready to start soldering parts and wires to the board.
The shield is certainly not needed for prototyping. I don't own any; I keep a handful of solderless breadboards around for the purpose. But if I were planning to build a permanent Arduino shield, that's where I'd start.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Rc car controller using the RC-switch library

simulate this circuit – Schematic created using CircuitLab
(Newbie in arduino)
Hi so i have a project which involves creating an rc car which uses the 433Mhz rf module and an arduino nano with a servo motor and an ultrasonic parking sensor.
I'm having problems with the code both on the transmitter and receiver,
Here is the code for the transmitter.
 #include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
// Assigning controller buttons to Digital Pins
 const int forward = 8;
 const int reverse = 9;
 const int rightTurn = 10;
 const int leftTurn = 11;

 int Fwd = 0
 int Bwd = 0
 int Lt  = 0
 int Rt  = 0

void setup () {
  pinMode (forward, INPUT);
  pinMode (reverse, INPUT);
  pinMode (rightTurn, INPUT);
  pinMode (leftTurn, INPUT);
  mySwitch.enableTransmit(7);
  Serial.begin (9600);         // Debugging only
  Serial.println ("Transmitting");
}

void loop () {
  Fwd = digitalRead(forward);
  Bwd = digitalRead(reverse);
  Rt  = digitalRead(rightTurn);
  Lt  = digitalRead(leftTurn);

  if (Fwd == HIGH) {
    mySwitch.send('1');
    Serial.println ("Forward");
    delay(100);
  }

  if (Bwd == HIGH) {
    mySwitch.send('2');
    Serial.println ("Reverse");
    delay(100);
  }

  if (Rt == HIGH) {
    mySwitch.send('3');
    Serial.println ("Left Turn");
    delay(100);
  }

  if (Lt == HIGH) {
    mySwitch.send('4');
    Serial.println ("Right Turn");
    delay(100);
  }
}

And here's the code for the receiver
#include <RCSwitch.h>
#include <Servo.h>

const int IN1 = 3;
const int IN2 = 4;
const int trigPin = 5;
const int echoPin = 6;
int distance = 0;

RCSwitch mySwitch = RCSwitch();
Servo myservo;

void setup () {
  mySwitch.enableReceive(2);
  myservo.attach(7);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  Serial.begin (9600);    // Debugging only
  Serial.println ("Receiver Ready");
}

void loop () {
 if (mySwitch.available()) {

    int value = mySwitch.getReceivedValue();

      if(value == '1') {
        forward ();
        Serial.println (" = forward");
      }

      if(value == '2'){
        backward ();
        Serial.println (" = backward");
      }

      if(value == '3') {
        left ();
        Serial.println (" = left");
      }

      if(value == '4') {
        right ();
        Serial.println (" = right");
      }
      Serial.print(" ");
    }

}

void forward () {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
}
long duration;
int value = mySwitch.getReceivedValue();
void backward () {
  if ((distance > 10)&& (value == '2'))
  {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, LOW);
  }
  else if ((distance < 10)&& (value == '2'))
  {
  digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW);
  }
  delayMicroseconds(10);
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance= duration*0.034/2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance); //distance is the returned integer,
}

void right () {
  myservo.write(0);
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
}

void left () {
  myservo.write(90);
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
}

The problem is when i run the code the buttons start getting pressed even if I'm not pressing them and even when i disconnect them from the arduino. and also the receiver cant receive any data.
Please help

Sounds as if your button pins are floating. Do you use a pulldown resistor for each button in your setup? If not, this is the problem.

ohh, yeah im not using any i just connect them to the gnd and their respective pins ,what value should i use?

Hi i added the circuit of the button

As you wrote in your comment, you didn't use  pullup or pulldown resistors for connecting the buttons. In this case the pin is floating, whenever the corresponding button is not pressed. It will pick up random noise from the environment and change it's state randomly.
A pullup or pulldown resistor defines a specific value for the pin, if the button is not pressed (LOW or HIGH). The value of such is a resistor is not critical, as long, as it isn't a too big load. Pick some value in the kiloohms (for example 10kOhm).
But you don't need external resistors for this. The Atmega328, which is the heart of the Arduino Nano, already has buildin pullup resistors for each digital output pin. You can activate them by using
pinMode(pin_number, INPUT_PULLUP);

In this case you will have to change the if-statements to check for LOW instead of HIGH and connect the button to ground instead of 5V, because with a pullup resistor in idle state the pin will be pulled up to 5V and the button can then pull it down to ground.

so i'd add another line of code with pinMode(9, 10)?

No, you have to change the lines with pinMode (forward, INPUT); and it's siblings to pinMode(forward, INPUT_PULLUP). And then you have to connect one button pin with the corresponding pin on Arduino and the other button pin to GND.

Ohh ok, thanks, i think that might solve the problem since i already have the pins of my buttons to GND and the pin it's set to on the program.

Thanks it actually solved the problem the pinMode(forward, INPUT_PULLUP) fixed it

another question, is the code for the receiver correct?

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arduino Force sensitive Resistor with an lcd
So we were asked to do something with a force sensitive resistor so naturally i thought of a project which takes the name of the main component which is force and applies it ,mine works by as  you apply more and more pressure to the sensor it takes this value and displays it on an lcd but the display should be a bar graph which increases as the pressure increases. the problem is i dont really know how to do a bar graph on a 16x2 lcd. Please help. (my lcd has an I2c)
here is my code for the pressure sensor so far
int fsrAnalogPin = 0; // FSR is connected to analog 0
int fsrReading;      // the analog reading from the FSR resistor divider

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}

ok so i improved my code and i finally got it this code displays the force detected by the fsr into a bar graph
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LcdBarGraphX.h>
#include<LcdBarGraph.h>

byte lcdNumCols = 20; // -- number of columns in the LCD

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);   // -- creating LCD instance

int fsrAnalogPin = 0; // FSR is connected to A0

// -- creating a 4 chars wide bars
LcdBarGraphX lbg0(&lcd, 16, 0, 0); // -- First line at column 0 and row 0 with 16 columns

void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
  lcd.begin(4, lcdNumCols); // start lcd with 2 rows and 16 columns
  lcd.clear();
  delay(100);
}

void loop(void) {
  lbg0.drawValue( analogRead(fsrAnalogPin), 9); // the 9  is the maximum range you want for pressure
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}

your question has nothing to do with a force sensor ... it is a question about drawing bar graphs on an LCD .... you should really edit your question and the title so that it reflects the actual question .... that way, people will find your question if they are researching graphing on an LCD

There's two ways you can do it: the easy way, and the fancy way.
The easy way really is easy.  Since the display can only display characters you just display characters - enough to represent a bar graph.
If you have a display with "Rom Code A00"* then character 255 is a solid block (▇) so you just print between 0 and 16 of them in a row.  0 is 0% and 16 is 100%. (If you have ROM Code A02 then you could just use #, or custom design a character - see below).
Force:▒▒▒▒▒▒▒▒▒▒
▇▇▇▇▇▇▇▇▇▒▒▒▒▒▒▒

Or with #:
Force:▒▒▒▒▒▒▒▒▒▒
#########▒▒▒▒▒▒▒

The fancy way is to use the programmable characters facility.  You would create 4 new characters that partially fill a block.  Each character is 5 pixels wide, so creating a character with 1 column of pixels set (▏), one with 2 set (▍), 3 set (▌) and 4 set (▋) (you already have all 5 set on in character 255 if you have ROM Code A00 - otherwise define a 5th with all 5 columns on).  Now you can be clever and work out:

How many full characters to print, and
Which of the extra characters to print on the end.

That gives you effectively 16*5 (80) pixels of horizontal resolution (albeit with a small gap between each set of 5 pixels).
Exactly how you do whichever of those methods you choose is now up to you.

*: ROM Code A00 is the character ROM with Japanese characters in the characters 128-255.  ROM Code A02 has European accented characters instead.

From the Library Manager, install the LcdBarGraphX library by Balazs Kelemen.
There are several examples there as well.

See also LcdBarGraph Library for Arduino. Prapec's github has the original fork for LcdBarGraphX.


text:
Arduino for loop
I am a beginner in Arduino programming. This is my program for 5 LEDs and 1 Button. The LEDs are supposed to light before I press the button. But the LEDs start immediately, even without pressing the button. How is it possible?
int sw7=7;
int timer=500;
int start=0;
int stopp=100;
void setup()
{
  for (int opin=1;opin<6;opin++)
  {
    pinMode(opin,OUTPUT);
    pinMode(sw7,INPUT);
  }
}

void loop()
{
  if (digitalRead (sw7)==LOW)
  {
    while (start<=stopp);
  }
  {
    for (int opin=1;opin<=5;opin++)
    {
      digitalWrite(opin,HIGH);
      delay(timer);
      digitalWrite(opin,LOW);
     }
  }
}

how did you wire the button? has it pull-down?

It's a large tack switch. 1 foot is on pin 7 in series with the other foot connected to 5v and the foot beside the foot that is connected in pin 7 is connected to ground. Is there nothing wrong with the program? Thank you.

I aligned your code. do you see how the for loop is outside of the if for the button?

no resistor? wire it this way and use mode INPUT_PULLUP https://www.arduino.cc/en/Tutorial/InputPullupSerial

try putting an else between }   {

@Juraj there is a resistor. I think it's there something wrong with the code.

@Juraj okay I'll wire it. I'll get back to you, thanks a lot!

@Gerben. void loop()
{
if (digitalRead (sw7)==LOW)
{
while (start<=stopp);
}
else
{
for (int opin=1;opin<=5;opin++)
{
like this?

How are the LEDs wired? +5 to anode, cathode to resistor, resistor to pin?  If so, then they turn on with a low output, and probably turn on right after the pinMode command.  Try a test - add a noticeable delay after the pinMode, see if that's when turn on. If so, then drive the outputs high after the pinMode to 'initialize' them, and change your code to turn them on with a Low instead of High.   Also, using INPUT_PULLUP on the switch and testing for a Low instead of a High will keep the switch input from floating around when it is not pressed.

why are you running this 5 times? pinMode(sw7,INPUT);

these two are the same thing The LEDs are supposed to light before I press the button. and LEDs start immediately ...... i think that you need to edit your question

Your line  while (start<=stopp); will put your sketch into an infinite loop. start will always be less than stopp, so that loop will never end and your program will freeze once it begins executing that while loop.

Several things:
You need to explicitly set your output pins to LOW in your setup method.
The code to set the sw7 to input should not be inside the loop.
You should probably connect your switch between sw7 and ground and use INPUT_PULLUP mode (in INPUT_PULLUP mode the line is connected to +5V through a "pull-up resistor" so that it reads HIGH until you press the button, and then it reads LOW. If you don't use either an input pull-up or pull-down resistor then the input tends to "float" and give bad readings.)
You say "The LEDs are supposed to light before I press the button. But the LEDs start immediately, even without pressing the button."
I'm not sure what you mean. What do you want to happen, exactly? Do you want the LEDs to be lit steadily, and then turn off or flash when you press the button?
The code below will turn off all the LEDs initially, then toggle between off and flashing on each (debounced) button press. Switch the value of idleLEDState to HIGH if you want the LEDs to be lit when they are not flashing.
#define flashDelay 50 //Delay between on and off state for LEDs
#define switchBounceDelay 100

uint8_t idleLEDState = LOW; //Change to HIGH
                            //if you want the LEDs to be lit when not flashing
bool flashLEDs = false;
bool ledsOn = false;
unsigned long nextFlashTime = 0;
unsigned long nextSwitchCheckTime = 0;

void setup() {
  pinMode(sw7, INPUT_PULLUP); //Connect the switch between sw7 and ground
  for (int opin=1;opin<6;opin++)
  {
    pinMode(opin,OUTPUT);
    digitalWrite(opin, idleLEDState);
  }
}

void loop() {

  //If it's time to check the switch, and it's being pulled LOW, toggle flashLEDs
  if (mills() > nextSwitchCheckTime && digitalRead(sw7) == LOW) {
    flashLEDs = !flashLEDs;
    nextSwitchCheckTime = millis() + switchBounceDelay;
  }

  if (!flashLEDs) {
    //IF we're not supposed to flash the LEDs, set them to their idle state
    for (int opin=1;opin<6;opin++) {
        digitalWrite(opin, idleLEDState);
     }
  } else if millis() > nextFlashTime {
    nextTime = millis() + flashDelay;
    ledsOn = !ledsOn;
    for (int opin=1;opin<6;opin++) {
        uint8_t newState = ledsOn ? HIGH : LOW;
        digitalWrite(opin, newState);
     }
}

I banged out the code above in the Stack Exchange editor. It likely contains a few typos. Please exert some effort to fix it and adapt it to your needs before posting back "Your code didn't work. I got error XYZ."

This is a sketch according to your requirements:
// pin mapping
int pin_map[] = {
  1,  // 0: led in pin 1
  2,  // 1: led in pin 2
  3,  // 2: led in pin 3
  4,  // 3: led in pin 4
  5,  // 4: led in pin 5
  7   // 5: button (pull-up)
};

int timeout_ms = 500;
int blink_ms = 100;

void setup()
{
  // setup pins
  for (int opin = 0; opin < 5; opin++) pinMode(pin_map[opin], OUTPUT);
  pinMode(pin_map[5], INPUT_PULLUP);

  // wait for activation
  while (millis() < timeout_ms)
  {
    // activate by button (off:pull-up on:GND)
    if (digitalRead (pin_map[5]) == LOW) break;
  }
}

void loop()
{
  for (int opin = 0; opin < 5; opin++)
  {
    // toggle LED
    int pin = pin_map[opin];
    pinMode(pin, !digitalRead(pin));
  }

  delay(blink_ms);
}

You will need avoid delay() usage if you need asynchronous tasks. Probably, you should study C language and practice with some hundred of sketchs to improve your code skills.

Putting the LED pins and the switch pins into the same array seems confusing. They do different things. I do see the value in using an array to store the LED pin assignments though. That way you can use any pins for the LEDs, even discontinuous pin numbers.


text:
How to stop transmission i2c on LCD 16x4 i2c
i want to try to stop communicaton I2C between arduino and lcd I2C but i don't see any command to stop this communication. I try with Wire.endTransmission or Wire.end but the transmission to the LCD continue without problem. I'm using this library NewliquidCrystal and inside no command for end transmission. I need to interupt that communicaton for have a good management of lcd or if know a new library with best features. Thank's for help

What do you mean "stop" communication? If you don't perform any LCD manipulation commands you won't be communicating, so just don't do anything if you don't want to do anything.

i wan't to interrupt communcication becouse after some time i have some spikes on i2c bus and lcd print casual char, and i thinked with interrupted communication i can avoid this stuff , thanks for help

No. If you have noise on the I2C bus you need to find and suppress the cause of that noise, or harden your I2C bus. The simplest way to harden the I2C bus is to not rely on the (completely incorrect) internal pullups on the GPIO pins and instead fit (protocol standard) 3.3kΩ pullup resistors.

I need to interupt that communicaton for have a good management of lcd or if know a new library with best features. Thank's for help

This sounds like a classical X-Y problem. You have decided on a solution and asking about some "magic" functionality without understanding the library or how the I2C bus works.
It would be better to try to describe the original issue, investigate, propose and discuss solutions. Basically better understand the original issue.
Back to your question:

Wire.endTransmission()

does not really do what you think. It marks the end of a block to be transmitted (previous Wire.write()) and starts the actual transmission to the slave.
This is what the manual says:

Wire.endTransmission()
Description
Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write().

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
USB reset fails on arduino due because of 5v on digital pins
I have the signal channels of four 5v magnetic encoders connected directly to the digital pins of the arduino due. I am aware that this is not allowed according to the specification which says that digital pins should only sink 3.3v but I have not encountered many problems with this setup until now and the encoders only sink 20mA.
This is the setup of one of the encoders, I only encounter the following problem only if I connect more than 2 encoders in this formation

The Due resets fine when I press the reset button, but when I reconnect USB, the Due crashes and is not able to run any code (tested a blink sketch).
I cannot change any of the circuitry because it is already in multiple PCBs. Does anybody have an idea why the 5v on the 3.3v tolerant pins is causing the reset over usb to fail and how I could fix this in software? It must be fixable in software as the arduino IDE manages to upload sketches while the encoders are connected. I tried to reset over USB by connecting with 1200 baud and setting DTR but that didnt work.
Thanks so much in advance, I hope my question was clear.
edit: I am aware I am doing things wrong here and that that is whats causing the issue. The problem is we soldered 20+ of those PCBs and I cannot simply make modifications, even simple ones. I am looking for ideas on how to hotfix something in software that I messed up in hardware.
edit edit: Honestly kinda disappointed with the hostility on here, am I being downvoted simply because I made mistake with the specification and am trying to find a workaround? I dont see how that makes it a bad question.

Your wondering why something isn't working right, when you know you are connecting 5v to a board that should only ever use 3.3v logic..........?

You're over-stressing the MCU and causing all sorts of horrible things to happen with the power rails. Of course nasty things are going to happen.
The only way to fix it is to change the circuitry.  Something as simple as adding a 1kΩ resistor in series with each of the input connections could be enough to sort it out.

Adding a resistor in series can be done by scraping away some of the soldermask, cutting the trace, and bridging the cut with a SMD resistor.


text:
How can the sensitivity of capacitive touch sensors be limited?
I have an Adafruit circuit playground classic, and the touch-pads are so very sensitive. From a centimeter away, they trigger.  I would be happy to just have regular inputs, or to have the sensitivity reduced. How can I do this?
To clarify, here is my code:
//keyboard control for TuxKart power Glove
#include <Adafruit_CircuitPlayground.h>
#include <Keyboard.h>
#include <Mouse.h>
// set pin numbers for the five buttons:
const int Fire = 6;
const int Nitro = 9;
const int Eagle = 10;
const int _Esc = 12;

bool slideSwitch;

void setup() { // initialize the buttons' inputs:
  pinMode(Fire, INPUT_PULLUP);
  pinMode(Nitro, INPUT_PULLUP);
  pinMode(Eagle, INPUT_PULLUP);
  pinMode(_Esc, INPUT_PULLUP);

  Serial.begin(9600);
  // initialize mouse control:
  //Mouse.begin();
  Keyboard.begin();
}

void loop() {
  if (!CircuitPlayground.slideSwitch()) {
    return;
  }

  // use the pushbuttons to control the keyboard:
  if (!digitalRead(Fire) == HIGH) {
    Keyboard.write('KEY_SPACE');
    Serial.println("F");
  }
  if (!digitalRead(Nitro) == HIGH) {
    Keyboard.write('n');
    Serial.println("U");
  }
  if (!digitalRead(Eagle) == HIGH) {
    Keyboard.write(0xB2);
    Serial.println("N");
  }
  if (!digitalRead(_Esc) == HIGH) {
    Keyboard.write(0xB1);
    Serial.println("K");
  }
delay(200);
}

This code or any other, where capacitive touch sensitivity has not been specified, yields pins having extreme sensitivity. I have read the comments, that say the MCU doesn't feature this natively. If that were true, how would the pins remain sensitive?
My solution to this is to set sensitivity so low, that it is negligible. If capacitive touch sensing is not specified, why am I getting that functionality? Why would this code give me capacitive touch sensing?
Ideally, I would disable the touch sensing somehow, or have the pins simply behave normally, like any other Arduino based device that doesn't have touch sense. But what I have guessed, (shown in code) doesn't work. If there is a more explicit way to specify that IO pins should act as normal pins, without capacitive touch sensing, I would surely like to know.

Please edit your question to include part numbers and links to part descriptions.  Also a good idea to include a  Minimal, Complete, and Verifiable example of code, to show what libraries you are using to read the sensors

How do you do the capacitive sensing? Libraries? Code? This information is still missing.

Im not doing it, in code, the hardware is doing it automaticly. I havent figured out how to disable it. I hoped that by not having it in code, that the functionality wouldn't be active, but it would seem to be the opposite

You wrote: “Im not doing it, in code, the hardware is doing it automaticly”. Wrong. This board is based on the ATmega32u4, which does not natively support touch sensing. I can detect touch with the appropriate code/library, but it cannot do it in a hardware-only way.

Then how do i get functionality of capacitive touch,  if my code doesn't use it. Why isnt it just disabled? I'm here for answers, guys, basing my questions on observations. If i knew already, I wouldn't be asking.

digitalRead(pin) is the wrong way to read capacitive touch inputs.
In the file from the example you linked in your answer, the reading is made by calling CircuitPlayground.readCap(pin, num_samples) and then the returning value is compared to a threshold.
const uint16_t TOUCH_THRESHOLD = 300;

...

if (CircuitPlayground.readCap(Fire) >= TOUCH_THRESHOLD) {
   Keyboard.write(KEY_SPACE);
   Serial.println('F');
}
...

You can change the sensitivity by changing TOUCH_THRESHOLD. You could also add and fiddle with the second argument to change the number of samples.

Its not the best method for finding a solution, perhaps, but I was tooling around in the Adafruit_CircuitPalyground repo, and found a macro for the Capacitive touch sensitivity.
The macro is:
#define CAP_THRESHOLD 300 // Threshold for a capacitive touch (higher = less sensitive).

Located here:
https://github.com/adafruit/Adafruit_CircuitPlayground/search?utf8=%E2%9C%93&q=CAP_THRESHOLD&type=
I'm reading more, and trying to find the libraries for capacitive touch. There may be a much better solution, but for now defining CAP_THRESHOLD works well enough.


text:
How to measure voltage with Arduino analog input
I'm totally new to Arduino and to electrodynamics in general.
I'm wondering what happens if I connect my digital pin to an analog input on Arduino, and make digitalWrite and analogRead on the according pins. Here are the options I can think about:

Just connect them directly - it is not a short circuit, is it?
Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?
Make a circuit: digital output -> resistor -> ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?

As you see, I'm really confused now. I would highly appreciate if someone could explain in detail what is happening in all the cases, with corresponding values for the current, voltage and resistance.

The more interesting cases are connecting the input such that there's a resistor between the input and the digital output and another resistor between the input and ground, forming a voltage divider.  Or connecting the input to a PWM output via a several kilohm resistor and connecting the input to ground via a several uF capacitor, forming a filter to smooth the PWM duty cycle into an analog voltage.

You can connect digital pin to analog input directly. That's not very interesting though, since you'll only see two values from the analog input (at least theoretically).
The digital pin gives out 0 or 5 Volts. The analog pin expects 0 to 5 Volts input. The only thing that matters to the analog input is the voltage with respect to ground. That can be between 0 to 5 volts (returned as 0...1023 by analogRead function).

Just connect them directly - it is not a short circuit, is it?

No, it's not a short circuit. In general, connecting anything to an input is not a short circuit. Connecting output to another output is potentially a short circuit.

Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?

This makes no difference compared to connecting them directly, unless the resistor value is very high (should be hundreds of kOhms or even MOhms to see a difference, I suppose), because almost no current flows to the input.

Make a circuit: digital output -> resistor -> ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?

This makes no other difference than that the resistor loads, i.e. draws current from, the digital output. If the resistor value is too small, then the digital output is unable to supply enough current so the 5 V voltage could become less than 5 V, or you could even burn the chip.

Thank you for the detailed answer!
I didn't get "you'll see the two values" - not only one, voltage? And I didn't get the last paragraph. Can it be explained with only I = U/R?

You see one value at a time, of course, but the value will be either 0 (digi-out LOW, 0 Volts) or 1023 (digi-out HIGH, 5 Volts). You cannot create, for example, 2.5 Volts with the digi-out, which is either on or off. The last paragraph, yes, I = U/R, and your digi-out has either 0 or 5 Volts, so I = 0 for LOW and I = 5 / R for HIGH digi-out state. If R is small, then I becomes high. The top limit is 20 mA for some Arduinos at least. If you use 250 Ohm R, then you'll get 20 mA from 5 Volts.

If you have a 250 ohm resistor from the digital pin to Gnd, and connect the digital pin to an analog input pin, then 20mA will flow thru the resistor to Gnd (5V/250 ohm = 20mA), while almost nothing flows into the analog input, as the max input current is 1uA per the datasheet, implying the input acts like a large resistor to Gnd: High input of 5V/.000001A = 5Meg-ohm.
I say acts because the input pin is the gate of a MOSFET, and a diode protection clamp to +5 and another to Gnd to limit the input voltage to -0.5 and Vcc+0.5V (so 5.5V with Vcc = 5V).
The diode clamps are only good for ~1mA (not shown in the data sheet, but discussed in an application note on detecting AC zero crossing), exceed that and you risk blowing the diode and/or the input pin and/or the chip (which will then feel warm or hot to the touch when it is powered up).
That's why you don't apply signals to unpowered chips - to prevent damaging the diode clamp circuits.


text:
Arduino Mega 2560 - TFT 3.5 Display is not working with libraries suggested
I attached two images of the shield.

I bought an Arduino Mega 2560 R3 with a TFT 3.5 Display shield in China.
What I know from my research is:

There are no data sheets available in the Internet.
The factory's web site, in China, is in Chinese, and there is no information in English.
I achieved to know the factory is www.mcufriend.com, because it is the only reference in the shield.
Apparently the drive to use is R61581.
Using suggested libraries from Henning Karlsen (http://www.henningkarlsen.com/electronics/library.php)
(UTFT, UTFT Geometry, tiny Fat, UTFT Tiny Fat, UTouch and UTFT buttons) . These libraries don't work with this shield.
Some people say that this shield requires 3.3 [Volts] to work, but the Vcc pin connected goes to 5V and it contains a Voltage regulator. I suppose it drops the voltage from 5[V] to 3.3[V] in the middle of the back side of the screen shield (see the upper photo - U1).
The specs that I found, say that this is a 262,144 Color 320x480 Dot Graphic LCD screen using a LCD driver a Si TFT Panel.
This screen includes a touch pad and a Micro SD memory reader.
After using the geometry test included in the library folder UTF Geometry mentioned on #5, and using all the drivers found in the documentation included by Henning Karlsen in a .pdf doc, I couldn't get this shield to work.

Does anyone know how to make this screen work?
I know is too much technology involved to be a fake shield, but it should be very useful to have this working. Do you agree with me?

In what way is it not working?

I drop down the testing software into the Mega, but the screen remains not showing any activity. Only the back light is on. I have an expensive lamp working, but it is not showing anything on it. I tried all the drivers.

The URL to the library mentioned in the OP's post is dead, and henningkarlsen.com appears to have moved to rinkydinkelectronics.com. The page may be now this one, Library: UTFT.

I have the same display. It has ILI9137 chip using 8-bit mode, so original Henning Karlsen UTF library doesn't work. You can find this library patched to support this display using Arduino MEGA at https://github.com/dgolda/UTFT
If display wouldn't work it is probably broken. I've received first piece broken - only backlight was working, but second and third was OK.


text:
State change detection with a colour sensor
I have added static variables to this code and instead of getting repeated notes whilst dwelling on green, I get a single note instead. This is what I wanted. However, my loop isn't allowing for a new note to be fired either when the sensor returns to a green colour. I'm afraid I'm not getting the hang of this!
  /*
  // TCS230 color recognition sensor
  // Sensor connection pins to Arduino are shown in comments

  Color Sensor      Arduino
  -----------      --------
  VCC               5V
  GND               GND
  s0                8
  s1                9
  s2                12
  s3                11
  OUT               10
  OE                GND
*/
#include <MIDI.h>

const int s0 = 8;
const int s1 = 9;
const int s2 = 12;
const int s3 = 11;
const int out = 10;

// LED pins connected to Arduino
int redLed = 5;
int greenLed = 6;
int blueLed = 7;
// Variables
int red = 0;
int green = 0;
int blue = 0;
int indeks = 0;
const int rgbr = 7;
const int rgbg = 6;
const int rgbb = 5;

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
  MIDI.begin();                      // Launch MIDI and listen to channel 4

  Serial.begin(9600);
  pinMode(s0, OUTPUT);
  pinMode(rgbr, OUTPUT);
  pinMode(rgbg, OUTPUT);
  pinMode(rgbb, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(out, INPUT);
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  digitalWrite(s0, HIGH);
  digitalWrite(s1, HIGH);
}

void loop()
{
  color();

  int tmpr = (((20 - red) - 10) * 30); //int tmpr=(((20-red)-10)*30);
  int tmpg = (((20 - green) - 10) * 30); //int tmpg=(((20-green)-10)*30);
  int tmpb = (((20 - blue) - 10) * 30); //  int tmpb=(((20-blue)-10)*30);

  if (tmpr < 0)
    tmpr = 0;

  if (tmpg < 0)
    tmpg = 0;

  if (tmpb < 0)
    tmpb = 0;

  if (tmpg > tmpb && tmpg > tmpr)
  { tmpb = 0;
    tmpr = 0;
  }
  analogWrite(rgbr, tmpr );
  analogWrite(rgbg, tmpg );
  analogWrite(rgbb, tmpb );

  static uint8_t noteOn;

  if (tmpg > 149 && tmpg < 151) {
    static uint8_t noteOn = 0;
    if (!noteOn) {
      noteOn = true;
      MIDI.sendNoteOn(79, 127, 1);    // Send a Note (pitch 79, velo 127 on channel 1)
      MIDI.sendControlChange(64, 127, 1);

    }
  }
  else {
    static uint8_t noteOn = 1;
    if (noteOn) {
      noteOn = false;
      MIDI.sendNoteOff(79, 0, 1);     // Stop the note
      MIDI.sendControlChange(64, 0, 1);

    }
  }
}

void color()
{
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  //count OUT, pRed, RED

  red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);

  digitalWrite(s3, HIGH);
  //count OUT, pBLUE, BLUE
  blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
  digitalWrite(s2, HIGH);
  //count OUT, pGreen, GREEN
  green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);

}

please include your attempts, so that we can see in which area you need help

Hello, I've replaced my code with new suggestions but still to no avail...

please format your code correctly ..... highlight all of the code text and click {} button

you are keeping track of only one note (any note)

problem is, that I don't know how to keep track of the note that I have

us an array (use boolean values, they are true/false) .... http://www.cplusplus.com/doc/tutorial/arrays/   .... when you play a note, set the corresponding array element .... when you stop the note, clear the corresponding array element

i re-read your question .... the thing that is adding to the difficulty is that you are trying to do multiple things during the development of your code ..... best thing to do is to start another sketch that is the same as this one with one major difference, there is no midi code .... replace the midi code with a subroutine that turns on an LED when the sensor detects green color and turns off the LED when the sensor no longer detects green color ............. when you have a solidly working program, then add the code for midi

That's the thing, I want the midi note or as you suggest, an LED, to light only the once whilst on green and not continually. When sensor values change and green is encountered again then the allocated note will play (once). I will strip back the code but I really thought the issue was simple, though unobtainable to me so far...

you have not defined the program's desired behavior correctly ..... you determined that the note should play when the sensor is over a green area ..... that is not what should happen ..... the note should play when the sensor enters a green area .....  those two behaviors are completely different ..... that means that you have to keep track of the background color

Because the MIDI library for Arduino does not keep track of which notes are on or off, you will have to do that yourself.
Add a static variable called noteOn that will hold a 0 or a 1, keeping track of whether you have a note turned on or not.
Then, when your loop() determines that it should turn on a note, it first checks if a note is already on. If the note is not already on (!noteOn), then send note on command, and set noteOn=true (same as noteOn=1) so that next time around, you won't send the note on command again.
void loop()
{
  static uint8_t noteOn;

  [...]

  if (tmpg > 149 && tmpg < 151) {
    if (!noteOn) {
      noteOn = true;
      MIDI.sendNoteOn(79, 127, 1);    // Send a Note (pitch 79, velo 127 on channel 1)
      MIDI.sendControlChange(64, 127, 1);
    }
  } else {
    if (noteOn) {
      noteOn = false;
      MIDI.sendNoteOff(79, 0, 1);     // Stop the note
      MIDI.sendControlChange(64, 0, 1);
    }
  }
}

Thanks jose can u c! Can you tell me what this means ( [...]) Also, what do you mean by keeping track of which notes are on or off? I have tried you code but unfortunately i still have the same problem of repeated notes...

[...] is just where I omitted some of your code that was unrelated to the relevant additions to answer the question.

I edited the answer to have a more explanation of what I mean by keeping track of which notes are on or off.

I thought I should attach my code with your additional code but i don't understand how or where I should post that!

Possibly should I edit my original post and replace it with the new code?

Yes, edit the question, add your revised attempt.

One more thing -- the logical AND operator is &&, not &.

I have changed the static variable noteOn to equal a '0' in the first if and then in the 'else if' I've changed it to a '1'. this gives me a first note played once but only once. I thought 'noteOn' was already keeping track but it isn't?


text:
Stuck reading an XBM image from JSON (U8g2lib)
What I'm trying to achieve is very simple, I'm using ArduinoJson lib to load a JSON from SPIFFS and trying to inject the image values in an Array to feed the small Oled display of the ESP32:
// This is the format the library expects
static const unsigned char image[] U8X8_PROGMEM  = {
0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x17 }

This is the JSON File:
   https://github.com/martinberlin/esp/blob/master/oled-128x64-xbm/data/1.json
The goal is to be able to generate little thumbnails after uploading an image for example, and display them in this Monochrome small display.
The problem is to convert this Json array into the format the library expects. And I tried many different ways and readed about it, without finding the right way to do it. So I though to share this here as a challenge and see if someone is also interested to get dynamic image thumbnails working in this display.
This is my sketch: (Needs /data upload since json example is there)
https://github.com/martinberlin/esp/tree/master/oled-128x64-xbm
#include "FS.h"
#include "SPIFFS.h"
#include <U8g2lib.h>
#include <ArduinoJson.h>
#include <Wire.h>

/*
  U8glib Example Overview:
    Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
    Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
    U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.

*/
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 15, /* data=*/ 4, /* reset=*/ 16);

static const unsigned char image[] U8X8_PROGMEM  = {
  0x00, 0xC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, 0xFF, 0xF7, 0xFF, 0xFF,
  0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x60, 0x00, 0x08, 0xFC, 0xE6,
  0xFF, 0xCD, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x1B, 0x00, 0x30,
  0x00, 0x04, 0x3C, 0xF8, 0xFF, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0x79, 0x40, 0x18, 0x00, 0x1C, 0x9E, 0xFC, 0xFF, 0x03, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0x00, 0x0C, 0x00, 0x0C, 0x4E, 0xFE,
  0xFF, 0x33, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3C, 0x00, 0x06,
  0x00, 0x0C, 0x77, 0xFF, 0xFF, 0x33, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0x7F, 0x7F, 0x00, 0x23, 0x00, 0xCE, 0xFF, 0xFF, 0xFF, 0x16, 0xF8, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x85, 0x01, 0x00, 0x1E, 0xFE, 0xFF,
  0x7F, 0x10, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC7, 0x01,
  0x80, 0x0F, 0xFF, 0xFF, 0x3F, 0x10, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0x67, 0x00, 0xD8, 0x1F, 0xFF, 0xFF, 0x7F, 0x10, 0xFE, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF};

const char* xtemp[1024]; // Temporary array to store JSON incoming Hex as string
const unsigned char* xbm[1024] U8X8_PROGMEM;

void setup(void) {
  Serial.begin(115200);
  // Read xbm from  json
  SPIFFS.begin();

   if (SPIFFS.exists("/1.json")) {
    Serial.println("1.json found in SPIFFS");
    File configFile = SPIFFS.open("/1.json", FILE_READ);
      if (configFile) {
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        //json.printTo(Serial);

        if (json.success()) {
          Serial.println("json.success");
          JsonArray& arr = json["xbm"];

          // using C++11 syntax (preferred):
          int c=0;

          for (auto value : arr) {
            // Assign the json array to xtemp
            xtemp[c] = value.as<char*>();

            //Serial.println(String(c)+":"+value.as<char*>()); // Right value
            c++;
          }

        } else {
          Serial.println("ERR load config");
        }

        configFile.close();
      }
   }
  u8g2.begin();
  u8g2.setDrawColor(0);
  u8g2.clearBuffer();

  Serial.println("cross_block_bits size:");
  Serial.print(sizeof(image));
  Serial.println(image[1]);

  //xbm = xtemp;

  Serial.println("xbm:");
  Serial.println(xtemp[1]);

 // Should be xbm (coming from json)   xbm
 // u8g2.drawXBM( 0, 0, 128, 64, xtemp); // Does not work since requires  'const uint8_t* {aka const unsigned char*}
  u8g2.drawXBM( 0, 0, 128, 64, image);

  u8g2.sendBuffer();
}

void loop(void) {

}

post the code directly in your question, don't link it.

Done, thanks! I though that an alternative way to do this would be to make my own loop and draw pixel per pixel, but anyways would be interesting to know if I can read a JSON array and give it to the library in the expected format.

u8g2.drawXBM( 0, 0, 128, 64, (const uint8_t *)xtemp);

Great idea Majenko, casting it to a uint8_t works. I still need to convert:
0xC0  Coming as string to it's int value

uint8_t val = strtol(stringval, NULL, 16)

Perfect. Now I have a last issue that I don't get why it's counting this way. I'm iterating this 1024 elements and storing them in a long unsigned int xbm[1024] (to mach strol type. At the end if I do a :
Serial.print(sizeof(xbm)); // Returns 4096. Still do not understand why
Reference after your recommendation: https://github.com/martinberlin/esp/commit/404814013c49b66338017164a2f36ed02676663b

Thanks @Majenko this let me understand much better how to transform. I will go back to the book on C++ variable types, since coming from PHP and the web world are difficult to understand for me

Found a solution, don't know if it's the right one, but re-writing an existing image array seems to be the key. Very strange, but it works correctly and now the JSON can be loaded and the image rendered. If you are interested to see how, the update is here in this location: https://github.com/martinberlin/esp/tree/master/oled-128x64-xbm

const char* xtemp[1024]; is array of 1024 pointers to char. const char xtemp[1024]; is array of 1024 chars

Thanks and credits to Majenko. Sorted it out, still I don't know why addressing an existing image works but targeting a new array doesn't. Anyways as proof-of-concept that an XBM Icon can be loaded from JSON it works. For anyone wanting to achieve this, here is the code, make sure to upload some JSON to Spiffs first:
/*
  GraphicsTest.ino
  Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
*/
#include "FS.h"
#include "SPIFFS.h"
#include <U8g2lib.h>
#include <ArduinoJson.h>
#include <Wire.h>

/*
  U8glib Example Overview:
    Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
    Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
    U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.

*/
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 15, /* data=*/ 4, /* reset=*/ 16);

static unsigned char image[] U8X8_PROGMEM  = {
  0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x17,
  0xFC, 0xFF, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00,
  0xFF, 0xFF, 0xFF, 0x14, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xF0, 0xFF, 0xFF,
  0xFF, 0x7F, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x14, 0xFD, 0xFF, 0xFF, 0xFF,
  0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x8F, 0xFF, 0x10,
  0x7E, 0xFF, 0xFF, 0xFF, 0x00, 0xFC, 0x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xFF, 0x33, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3C, 0x00, 0x06,
  0x00, 0x0C, 0x77, 0xFF, 0xFF, 0x33, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0x7F, 0x7F, 0x00, 0x23, 0x00, 0xCE, 0xFF, 0xFF, 0xFF, 0x16, 0xF8, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x85, 0x01, 0x00, 0x1E, 0xFE, 0xFF,
  0x7F, 0x10, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC7, 0x01,
  0x80, 0x0F, 0xFF, 0xFF, 0x3F, 0x10, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0x67, 0x00, 0xD8, 0x1F, 0xFF, 0xFF, 0x7F, 0x10, 0xFE, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF};

// Using this new array I could not get it work. Rewriting image works
long unsigned int xbm[1024];

void setup(void) {
  Serial.begin(115200);
  // Read xbm from  json
  SPIFFS.begin();

   if (SPIFFS.exists("/1.json")) {
    Serial.println("1.json found in SPIFFS");
    File configFile = SPIFFS.open("/2.json", FILE_READ);
      if (configFile) {
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        //json.printTo(Serial);

        if (json.success()) {
          Serial.println("json.success Size of xbm array");

          JsonArray& arr = json["xbm"];

        Serial.print(sizeof(arr));
          // using C++11 syntax (preferred):
          int c=0;
          const char* tempx;
          for (auto value : arr) {
            // Assign the json array to xtemp
            tempx = value.as<char*>();

            image[c] = strtol(tempx, NULL, 16);

              //Serial.print(strtol(tempx, NULL, 16)); //Thx. Majenko
              if (c<10) {
              Serial.print("i:");Serial.print(image[c]);Serial.print(" ");
              }
            c++;
          }
          Serial.print("Final c count:"+String(c));

        } else {
          Serial.println("ERR loading JSON");
        }

        configFile.close();
      }
   }
  u8g2.begin();
  u8g2.setDrawColor(0);
  u8g2.clearBuffer();

  Serial.print("image size:");
  Serial.print(sizeof(image));Serial.println();  // Here is 4096 also 4 times bigger, if I use a new array (WHY?)
  // Send the JSON array to oled display
  u8g2.drawXBM( 0, 0, 128, 64, (const uint8_t *)image);
  u8g2.sendBuffer();
}

void loop(void) {

}

why long unsigned int xbm[1024]; and not byte xbm[1024];, which would be the same as new char[size] for the existing file?

Yes that will work. But the issue is that I'm not even using this new one, but filling the already declared image. Using the new one, at the end of the 1024 pixels loop, you end up having 4x more (4096) and I still don't know why.

Also it sounds to me that using this: long unsigned int xbm[1024]
It's reading somehow the 4 chars from every pixel ( 0x00 ) but that would be impossible since we are transforming this HEX into an integer. But well cool thing is that it works just overwriting a previous image

a hex number with two hex digits fits into one byte. FF is in binary 11111111. 0F hex is 00001111 binary. that is way hex is used


text:
Need some help in coding a "timer" in an if else statement
I want to code something like a "timer" (don't know what to call it) in an if else statement in my arduino uno.
Basically I have 2 buttons. If the button1 is pressed and button2 is also pressed in a certain amount of time (let's say 3 seconds), the code will execute. If button1 is pressed but button2 is not pressed within 3 seconds then it will loop back up. How do I go about writing this code?
I've included a flowchart to make my question clearer.
Thanks all :)
if(digitalRead(button1) == LOW)       // this is where I need help
{
  if(digitalRead(selectbutton) == LOW)
  {
    for(x=1; x<=30; x++)
    {
      digitalWrite(dir, HIGH);
      delayMicroseconds(10);
      time_now = millis();
      digitalWrite(led, HIGH);
      while(millis() < time_now + 50)
      {
      }

      time_now = millis();
      digitalWrite(led, LOW);
      while(millis() < time_now + 50)
      {
      }
    }
    x=0;
  }
}

else if(digitalRead(button2) == LOW)    //same here >_<
{
  if(digitalRead(selectbutton) == LOW)
  {
    for(x=1; x<=10; x++)
    {
      digitalWrite(dir, LOW);
      delayMicroseconds(10);
      time_now = millis();
      digitalWrite(led, HIGH);
      while(millis() < time_now + 150)
      {
      }

      time_now = millis();
      digitalWrite(led, LOW);
      while(millis() < time_now + 150)
      {
      }
    }
    x=0;
  }
}

}

Hi, I've edited my post. Hope you can help. :)

Your flowchart seems to be in conflict with the code.
button1 and button2 are self-explainatory, but what is the selectButton?
Here's some code which may accomplish what you're trying to do:
uint8_t bool_waitforbutton2 = 0;
uint32_t num_timeatbutton1 = 0;
void loop() {
  //your other looping code here
  if(digitalRead(button1) == LOW) {
    num_timeatbutton1 = millis();
    bool_waitforbutton2 = 1;
  }
  if(bool_waitforbutton2 == 1 && digitalRead(button2) == LOW){
    bool_waitforbutton2 = 0;
    //Your code here
  }
  if (millis() > (num_timeatbutton1 + 3000)) {
    bool_waitforbutton2 = 0;
  }
}

This would give you 3000 ms to press button2 after you've let go of button1 to execute your code, otherwise the "readyness-flag" bool_waitforbutton2 is reset.

sorry for not clarifying, button1 is for choosing the first function, and selectbutton is for confirming to run function 1. Likewise for button2, it is to select function 2, and selectbutton is to confirm.

A flowchart is not bad, but it's not really the most appropriate kind of
diagram for this sort of problems. You should try to think in terms of
finite state machines instead, which is a very useful concept
whenever you try to implement “reactive” systems, i.e. systems that have
to react to some kind of input.
Here is your problem, as I understand it, translated into a state
diagram:

This system has two states:

“waiting”, when it waits for the first button to be pressed
“stand by” when the first button has been pressed and it waits for the
second.

Pressing button 1 makes a transition from “waiting” to “stand by”. The
transition back to the initial “waiting” state can be triggered by two
distinct events:

3 seconds spent in the “stand by” state
the user pressing button 2.

Note that in the second case, the system runs your code while making the
transition.
Once you have the state diagram, and assuming you have read (and
understood) the finite state machine tutorial I linked to, translating
the diagram into code is almost trivial.


text:
Getting more current through an LED array
I have an Arduino Uno controlling an array of 24 LEDs (datasheet).  I understand these LEDs are ultraviolet and have a forward current of 0.5A.  My power source (12V 2A) is wired to a switch which is then wired to the LED array and Arduino.  I should probably use a 12V 4A power source but was worried if too much current would go to the Arduino.  As per my attached diagram, the Arduino and LED array are in parallel.  I would like to get more current through my LEDs to increase their brightness.  What would be the best way to do this?
Updated: I tried adding a 100 Ohm resistor (where R11 is located) but the Arduino wasn't drawing enough power to turn on my LCD.  And then I tried a 1 Ohm resistor instead but the resistor burned out.  Unfortunately, I threw out the resistor and don't have a picture of it.  I believe the correct value should be ~47 Ohm so I have added that resistance as R11.  However, I haven't tested it yet as I want to make sure it's correct.  (12V - 6V) = 130mA * R >>> R = 46.15 Ohm.  I used a voltage drop of 6V so that at least 5V is still going into the Arduino (12V - 6V = 6V which is greater than 5V).  I measured the current through a multimeter to be 130mA.

Please edit your question and/or the  diagram to include values for R1–R9.  (R1-R8 have a lot to do with how much current flows.) Also edit your question to indicate whether you know the spec sheet is for a UV LED that does not produce visible light and it is specified for 1/2 amp forward current so that 8 strands of LEDs would take 4 amps, which a 12 V, 2 A supply can't handle.  Also say where the 1Ω resistor that burned out was located and add a picture of the burned out resistor

@Padraig, regardless if my answer works for you - please do as James Waldby requests and reword your question so that more people can make use of this exchange of information.

The current a bipolar transistor configured as a common emitter amplifier will allow from its collector to its emitter is equal to its beta time the base to emitter current.
A beta of 100 is common for many transistors. Assuming this information is close enough to your transistor, we can choose a base series resistance suitable for the collector to emitter current desired.
For example if you were using a 5 volt microprocessor and the voltage drop across the base to emitter was the usual 0.7 volts for silicon semiconductors and you had a base series resistor of 10Kohms:
V = I * R
V = 5 - 0.7 = 4.3 volts
R = 10000 ohms
I = 4.3/10000 = 0.43mA
I(ce) = Beta * 0.43mA
I(ce) = 100 * 0.43mA = 43mA

You could pass up to 43mA from the collector to the emitter.  If that is not enough,you can lowered the base resistor to 1Kohms:
R = 1000 ohms
I = 4.3/1000 = 4.3mA
I(ce) = Beta * 4.3mA
I(ce) = 100 * 4.3mA = 430mA

And increase the current to 430mA.  You still need to verify that the processor can supply the current to control the transistor (4.3mA as calculated above) as well as pick a transistor of sufficient capacity to handle the load.
If a beta of about 100 is not enough, consider using a Darlington transistor arrangement. This type of "2 transistor" device has a gain of the product of each individual transistor's beta.  So, it is common for such a device to have a beta of 10000!  Using this device, you can use a much larger base resistor and still be able to switch more current.

I tried adding a 100 Ohm resistor (where R11 is located) but the Arduino wasn't drawing enough power to turn on my LCD.

You should not have a resistor in the Arduino's supply line at all.

And then I tried a 1 Ohm resistor instead but the resistor burned out.

If you really wanted to have one to share the heat load of the on-board regulator, it would need to be a power resistor of appropriate wattage rating.

I believe the correct value should be ~47 Ohm so I have added that resistance as R11...I used a voltage drop of 6V so that at least 5V is still going into the Arduino (12V - 6V = 6V which is greater than 5V). I measured the current through a multimeter to be 130mA.

This is incorrect.
The Arduino's regulator needs something like 7 volts input to operate correctly.
The power drawn by the Arduino will not be fixed, it will depend on what it is doing, what I/Os are exerted against what loads, and other things like the LCD you apparently have.
Likely, if you want to use a power resistor you should design it to drop no more than half of the difference between the supply voltage and the regulator dropout voltage, under conditions of maximum load.  A fixed power resistor cannot be used to replace the variable power resistor that is a linear regulator; at most it can be used to offset some of the fixed part of the resistance and resulting thermal load.  But you still have to leave all of the variable part plus a healthy margin for the regulator to handle, or it won't be able to regulate.
It would be simpler to just put a heatsink on the regulator.


text:
Problems with I2C connection on ESP8266 - 12F, which pins should I use?
Previously I had pined the temp/hum sensor HDC1080 with an Arduino using this sketch and everything worked fine. Now I want to run it over an ESP-12F, I uploaded it but it has issues at the time of establishing I2C connection. Basically, I'm not sure if at the end of setup() the I2C connection has actually begun, because I get this at the serial monitor:

As far as I see, the code skips everything related to Wire library. I blame it on the SDA/SCL pins, but actually none of the pins are working for me. I found that default I2C GPIO's are 2 and 14, I tried with them and got no result; later I tried with 12/16, as the commented Wire.begin line says, but it was the same. I even read some possible solutions in this post but I not even have the mentioned libraries.
Could you give me any suggestion, please? This is the sketch I'm using:
#include <Wire.h>

#define HDC 0x40 //B1000000 MSB
#define cociente 65536 //2^16

uint16_t humrawvalue;  //Raw data value, MS byte = valmsb, LS byte = vallsb
uint16_t temrawvalue;  //Raw data value, MS byte = valmsb, LS byte = vallsb
uint8_t humvalmsb, humvallsb;  //Raw 8-bit byte of humidity
uint8_t temvalmsb, temvallsb;  //Raw 8-bit byte of temperature
int incomingByte = 0; //Action input
float humidity, temperature;

void setup() {
  delay(100);
  Serial.begin(9600);
  delay(100);
  Serial.println("Hello");
  //Wire.begin(12,16);
  Wire.begin();
  Wire.setClockStretchLimit(1500);
}

void loop() {
  if (Serial.available() > 0) {    //User presses 1 to start sensor reading
    // read the incoming byte:
    incomingByte = Serial.read();
    yield();
    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }

  Serial.println("---g-");  //Just guideline

  if (incomingByte == 49){
    Serial.println("IIIII");  //Just guideline
    Wire.beginTransmission(HDC);
    Wire.write(0x00);
    Wire.endTransmission(true);
    delay(200);

    Wire.requestFrom(HDC,4,true); //It asks for 4 bytes, 2 bytes per register
    if(Wire.available()){
      Serial.println("     ");
      Serial.println("Measuring: ");
      temvalmsb = Wire.read();
      temvallsb = Wire.read();
      humvalmsb = Wire.read();
      humvallsb = Wire.read();

      Serial.println("====TEMPERATURE====");
      Serial.print("MSB: "); Serial.println(temvalmsb, BIN);
      Serial.print("LSB: "); Serial.println(temvallsb, BIN);
      temrawvalue = temvalmsb <<8| temvallsb; //Locates each byte in its proper place
      Serial.print("Temp: "); Serial.println(temrawvalue, BIN);
      temperature = ((float)temrawvalue/(float)cociente)*165.0-40.0;
      Serial.print("Temperatura [C]: "); Serial.println(temperature);

      Serial.println("====HUMIDITY====");
      Serial.print("MSB: "); Serial.println(humvalmsb, BIN);
      Serial.print("LSB: "); Serial.println(humvallsb, BIN);
      humrawvalue = humvalmsb <<8| humvallsb;
      Serial.print("Hum: "); Serial.println(humrawvalue, BIN);
      humidity = ((float)humrawvalue/(float)cociente)*100.0;
      Serial.print("Humidity [%]: "); Serial.println(humidity);

      Serial.println("     ");
      delay(3000);
    }
  }
  Serial.println("++++"); //Just guideline
  delay(3000);
}

Regards!

2 and 14? i thought 4+5 were the hardware i2c pins... if you don't specify, that what's used

@dandavis that's the main problem, each datasheet shows different information about I2C. I just tried with 4,5 and testing the signal on an scope but there's no difference,  I just get  a DC signal

Is the device a 5V device?

Update: it never worked. ESP-12F was still very unstable, what made it impossible to connect this specific sensor. With serial protocol for other devices the micro did it fine, but struggled when using I2C

Unlike most Arduinos, the ESP8266 doesn't have a hardware TWI, so I²C is bit-banged in software. This means that you can use any GPIO pins. By default, Wire.begin() initializes pins 4 (SDA) and 5 (SCL), but you can specify other pins using Wire.begin(int sda, int scl).
Documentation
(Note: the datasheet specifies GPIO2 as SDA and GPIO14 as SCL, but that doesn't matter, AFAIK, it's just a convention.)

Wire doesn't work on ESP8266. See github issue: https://github.com/esp8266/Arduino/issues/3046

Are you referring the I2C pins on the Arduino? You could just skip the Arduino and wire it direct to the ESP8266 and in your code define which pins you are using for I2C or amend the library accordingly. If you go down this route, make sure you use the correct I2C scanner for the ESP8266. Which can be found on this Instructable, otherwise your I2C won't be detected.
http://www.instructables.com/id/ESP8266-I2C-PORT-and-Address-Scanner/
If you do stick with the Arduino, make sure the library is using the right address, again checking using the Arduino I2C scanner sketch to find which I2C address it is using.
https://playground.arduino.cc/Main/I2cScanner


text:
How to burn Arduino Bootloader on ATmega168PA-PU?
How can I burn the Arduino Bootloader on an ATmega168PA-PU with an Arduino Uno?

I have a bootloader-programmer sketch here:
http://www.gammon.com.au/bootloader
Basically you connect up the boards like this:
Arduino Uno         Target ATmega168PA

D10 (SS)            Reset (pin 1)
D11 (MOSI)          MOSI  (pin 17)
D12 (MISO)          MISO  (pin 18)
D13 (SCK)           SCK   (pin 19)

Gnd                 Gnd   (pins 8 & 22)
+5V                 +5V   (pins 7 & 20)

Then download the sketch from GitHub - the one you want is in the Atmega_Board_Programmer folder. Run that and follow the instructions in the Serial Monitor.
For more information see the link above.

The official Arduino documentation has detailed instructions on how to transform Arduino board into an ISP.
https://www.arduino.cc/en/Tutorial/ArduinoISP


text:
Arduino Uno with CC3000 WiFi Shield cannot be initialized
I am working on an Arduino Uno and CC3000 WiFi shield. I interfaced it over my Arduino and added the SparkFun library SFE_CC3000_Library. Then I opened the TestBoard example, but it hangs on setup in the first command wifi.init().
How can I solve this problem, and how can I enable debug mode?
Here's the code
#include <SPI.h>
#include <SFE_CC3000.h>
#include <utility/netapp.h>

#define DEBUG     1
// Pins
#define CC3000_INT      2   // Needs to be an interrupt pin (D2/D3)
#define CC3000_EN       7   // Can be any digital pin
#define CC3000_CS       10  // Preferred is pin 10 on Uno

// Constants
#define FW_VER_LEN      2   // Length of firmware version in bytes
#define MAC_ADDR_LEN    6   // Length of MAC address in bytes

// Global Variables
SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);

void setup() {

  int i;
  unsigned char fw_ver[FW_VER_LEN];
  unsigned char mac_addr[MAC_ADDR_LEN];

  // Initialize Serial port
  Serial.begin(115200);
  Serial.println();
  Serial.println("----------------------------");
  Serial.println("SparkFun CC3000 - Board Test");
  Serial.println("----------------------------");

  // Initialize CC3000 (configure SPI communications)
  if ( wifi.init() ) {
    digitalWrite(13, HIGH);
    Serial.println("CC3000 initialization complete");
  } else {
    Serial.println("Something went wrong during CC3000 init!");
  }

  // Read and display CC3000 firmware version
  if ( wifi.getFirmwareVersion(fw_ver) ) {
    Serial.print("Firmware version: ");
    Serial.print(fw_ver[0], DEC);
    Serial.print(".");
    Serial.print(fw_ver[1], DEC);
    Serial.println();
  } else {
    Serial.println("Could not read firmware version from CC3000");
  }

  // Read and display CC3000 MAC address
  if ( wifi.getMacAddress(mac_addr) ) {
    Serial.print("MAC address: ");
    for ( i = 0; i < MAC_ADDR_LEN; i++ ) {
      if ( mac_addr[i] < 0x10 ) {
        Serial.print("0");
      }
      Serial.print(mac_addr[i], HEX);
      if ( i < MAC_ADDR_LEN - 1 ) {
        Serial.print(":");
      }
    }
    Serial.println();
  } else {
    Serial.println("Could not read MAC address from CC3000");
  }

  // Done!
  Serial.println("Finished board test");

}

void loop() {

  // Do nothing
  delay(1000);
  Serial.println("Loop_Problem");

    }

Solved it, the problem was because the SparkFun library was not working with my shield. I replaced it using the Adafruit_CC3000_Library and now it works fine.

I was having the same problem with the ethernet shield (and i still have it). In my case it was caused by the network router. When my modem/router couldn't connect to the net (bad weather etc...) the shield couldn't take an IP and the initialaization was failing every time just because i was disconnected from the internet. The library works almost the same way. Basicaly you have to make sure it can connect.

Thanks for sharing solution with me. I solved it using another library. Solution is shared above.


text:
3.3V, 5V and 9V pins on Arduino
On my Arduino Uno R3 and Arduino Mega R3, there are 5V and 3.3V pins.
However on this page Introduction to the Arduino Board, there is a 5V and 9V pin but no 3.3V pin. The page at Arduino: What Adapter? also mentions a 9V pin.
Why is there a discrepency?

You've just made the argument that the Arduino team needs to put a brightly colored disclaimer at the top of these older reference pages that refer people to the current revision of the hardware. This version of the Arduino is really, really old by Internet standards.

The link you provide looks rather old and I don't think it applies to UNO Revision 3 as it has more pins than on the diagram you show.
I suggest you rather take a look at this Arduino UNO link which contains uptodate information about the UNO; in there you will see that for R3, the "power rail" has been extended and has the following pins, left to right:

1 unlabeled pin (can't remember what it is)
1 IOREF pin (used by shields to know if they should operate as 3.3V or 5V devices)
3.3V regulated output
5V regulated output
2 GND pins
Vin pin: this pin can be used in 2 different ways:

either as a voltage supply input (instead of using the power plug or the USB); the input voltage should be in 7-12V range and will be regulated internally (by the board circuits) to 5V
or an output supply voltage (if you plugged voltage supply through the power plug or the USB plug) that is a "copy" of the voltage input through the power plug or USB plug (not regulated yet)

There are three power supply pins on the Arduino Uno and on the Mega:

5V - Labelled as 5V. Can be used to power other 5V devices.
3.3V - Labelled as 3.3V. Can be used to power other 3.3V devices.
Vin - This also referred to as the 9V pin that is shown in the schematic. This is used to power the Arduino board itself, usually using a 9V battery.

Note that the Vin is whatever the board gets, so it can be more or less than 9V as well, depending on how the board is hooked up itself. Also the 5V pin can be less than 5V if you underpower the Arduino board itself.