Jobi-Wan:
Oh and by the way, this doesn't do what you think it does:if(estado000 = 1)
{
There is a difference between = and == operators. The 1st one is for assignment, the 2nd if for comparison. Look at other if's where values are being compared. So your condition is always true and you see output 9 go high but never low again.
Here is the new code.
I have forgotten the variable "estado000".
I have declared two new variables, "index" and "value". "Index" is the entry number that changes. "Value" is 1 or 0. It has not been difficult to find the entry number that goes from 0 to 1. But how to find the entry number that passes in 1 to 0?
//____________________________________________
//74HC595=====================================
/* A continuación te pongo cómo tienes que conectar el primer chip
* al Arduino. Ten en cuenta que los pines se numeran del 1 al 16
* desde el inferior izquiero (1), en el sentido contrario al movi-
* miento de las agujas del reloj, viendo la muesca del chip a la
* izquierda, terminando así en el 16, en la esquina superior iz-
* quierda, que es Vcc.
*/
int SER_Pin = 6; //pin 14 on the 75HC595
int RCLK_Pin = 7; //pin 12 on the 75HC595
int SRCLK_Pin = 8; //pin 11 on the 75HC595
//How many of the shift registers - change this
#define number_of_74hc595s 20
//do not touch
#define numOfRegisterPins number_of_74hc595s *8
boolean registers[numOfRegisterPins];
////////////////////////
// int estado000 = 1;
////////////////////////
//____________________________________________
//74HC165=====================================
/* A continuación te pongo cómo tienes que conectar el primer chip
* al Arduino. Ten en cuenta que los pines se numeran del 1 al 16
* desde el inferior izquiero (1), en el sentido contrario al movi-
* miento de las agujas del reloj, viendo la muesca del chip a la
* izquierda, terminando así en el 16, en la esquina superior iz-
* quierda, que es Vcc.
* El pin 15 lo he puesto a 9 y rula, así que así queda.
*/
const uint8_t pin_PL = 10; // to all pins 1
const uint8_t pin_CP = 11; // to all pins 2
const uint8_t pin_Q7 = 12; // to pin 9 of the 1ast chip.
//pin 10 of each chip to pin 9 of next chip
int index;
int value;
//____________________________________________
//Pantalla20x4·I2C============================
/*Conecta los cables SDA a SDA y SCL a SCL, calamar.*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f,20,4);
//Aquí originalmente ponía 0x24. Pues no. Hay que poner 0x3f y rula.
//////////////////////////////////////////////
//////////////////////////////////////////////
void setup(){
//____________________________________________
//74HC595=====================================
pinMode(SER_Pin, OUTPUT);
pinMode(RCLK_Pin, OUTPUT);
pinMode(SRCLK_Pin, OUTPUT);
//reset all register pins
clearRegisters();
writeRegisters();
//____________________________________________
//74HC165=====================================
Serial.begin(115200);
pinMode(pin_PL, OUTPUT);
pinMode(pin_CP, OUTPUT);
pinMode(pin_Q7, INPUT);
digitalWrite(pin_PL, HIGH);
digitalWrite(pin_CP, HIGH);
//____________________________________________
//Pantalla20x4·I2C============================
//Iniciamos el fondo retroiluminado
lcd.backlight();
//lcd.noBacklight();
//Iniciamos la pantalla
lcd.init();
//LCD.
lcd.setCursor(0,0);
lcd.print(" Universidad de ");//Escribir en la LCD
lcd.setCursor(0,1);
lcd.print(" Salamanca ");//Escribir en la LCD
lcd.setCursor(0,2);
lcd.print(" EPS de Zamora ");//Escribir en la LCD
lcd.setCursor(0,3);
lcd.print(" Laboratorio TIT ");//Escribir en la LCD
//delay(1000);
}
//____________________________________________
//74HC595=====================================
void clearRegisters()
{
//set all register pins to LOW
for(int i = numOfRegisterPins - 1; i >= 0; i--)
{
registers[i] = LOW;
}
}
void writeRegisters()
{
//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
digitalWrite(RCLK_Pin, LOW);
//for(int i = numOfRegisterPins - 1; i >= 0; i--){
for(int i = numOfRegisterPins; i >= 1; i--)
{
digitalWrite(SRCLK_Pin, LOW);
int val = registers[i];
digitalWrite(SER_Pin, val);
digitalWrite(SRCLK_Pin, HIGH);
}
digitalWrite(RCLK_Pin, HIGH);
}
void setRegisterPin(int index, int value)
{
//set an individual pin HIGH or LOW
///Serial.println();
Serial.print(index);
Serial.print(value);
Serial.println();
registers[index] = value;
//writeRegisters();
}
//////////////////////////////////////////////
//////////////////////////////////////////////
void loop(){
//____________________________________________
//74HC595=====================================
//Serial.println(boton01);
//if(estado000 = 1)
//{
// setRegisterPin(1, HIGH);
// estado000 = 0;
//}
//else
//{
// setRegisterPin(1, LOW);
// estado000 = 1;
//}
////////////////////////
writeRegisters();
//MUST BE CALLED TO DISPLAY CHANGES
//Only call once after the values are set how you need.
//____________________________________________
//74HC165=====================================
// Latch data from input pins into shift registers
digitalWrite(pin_PL, LOW);
digitalWrite(pin_PL, HIGH);
/* Aquí tienes también que intervenir. En el bucle tienes que
* cambiar el parámetro "n" en "i < n". Tienes que poner el
* número total de pines que quieres que se lean. Este número
* será igual al número de chips x 8 (esto ya es para logsianos).
*/
// Read all bits from all shift registers one by one
for (int i = 0; i < 80; i++)
{
if (digitalRead(pin_Q7) == HIGH)
{
//Serial.print("1");
index = i;
value = HIGH;
setRegisterPin(index, value);
}
else
{
//Serial.print("0");
index = i;
value = LOW;
//setRegisterPin(index, value);
}
// Clock pulse to shift to the next bit
digitalWrite(pin_CP, LOW);
digitalWrite(pin_CP, HIGH);
}
//Serial.print(digitalRead(pin_Q7));
///Serial.println();
//Serial.print(estado000);
//Serial.println();
//____________________________________________
//Pantalla20x4·I2C============================
// lcd.clear();//Limpiamos la LCD
// lcd.print("Primera linea");//Escribimos en la primera linea
// lcd.setCursor(0,1);//Saltamos a la segunda linea
// lcd.print("Segunda linea");//Escribimos en la segunda linea
// lcd.setCursor(0,2);//Saltamos a la tercera linea
// lcd.print("Tercera linea");//Escribimos en la tercera linea
// lcd.setCursor(0,3);//Saltamos a la cuarta linea
// lcd.print("Cuarta linea");//Escribimos en la cuarta linea
//Tiempo de espera para que reinicie el ciclo
//delay(500);
}