hello everyone
im having a problem in my code on how can use color sensor and IR sensor in a boolean if statement
your help will be greatfull
In the Arduino IDE, click on Edit, then Copy for Forum, that will copy your code.
Then come back here and just do a paste.
Your topic has been moved. Please do not post in « Uncategorized »; see the sticky topics in Uncategorized - Arduino Forum.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an « About the _____ category » topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the « How to get the best out of this forum » guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
It sounds like a line 42 problem.
How is a color sensor to be used in a voting system? Would you not just want switches, and maybe a display?
i have the display screen in lcd but just the color sensor is the one failing me to connect that IR sensor to accept sustain color of ballot papers
//imports
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#include <WiFi.h>
#include <WebSocketsServer.h>
LiquidCrystal_PCF8574 screen(0x27);
//variables for counter
int IRPin = 27;
int n = 0;
int oldValue = 1;
//sample data
int totalPopulation = 480000;
int voters = 360000;
int nonVoter = 120000;
// TCS230 or TCS3200 pins wiring to Arduino
#define S0 19
#define S1 15
#define S2 2
#define S3 4
#define sensorOut 18
// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;
// Stores the red. green and blue colors
int redColor = 0;
int greenColor = 0;
int blueColor = 0;
//wifi variables
//const char* ssid = "@idiot";
//const char* password = "hook5000";
const char* ssid = "idit2";
const char* password = "Kagwa2015";
//variables for websockets
WebSocketsServer webSocket(81);
void setup() {
Serial.begin(115200);
pinMode(IRPin, INPUT);
color_Intialization();
screenInitailization();
wifi();
// websocket initialization
webSocket.begin();
webSocket.onEvent(webSocketEvent);
}
void loop() {
read_Colors();
if (isBlueColor()) {
Serial.println("Blue color is detected");
} else {
Serial.println("Invalid color");
}
delay(10);
//websocket loop
webSocket.loop();
if (digitalRead(IRPin) == 0 && oldValue == 1&&isBlueColor()) {
oldValue = 0;
n = n + 1;
String votes = String(n);
countPrint();
webSocket.broadcastTXT(votes); //send to web
screen.setCursor(0, 3);
screen.print("vote :posted");
} else {
oldValue = 1;
}
}
thats how it is
Thank you for posting the code, but please, use the <CODE> button to wrap your formatted code in a code block. See Post #7 for instructions.
what do you mean by that i donot get it
In your IDE, format your code using CTRL-T, then copy your code using CTRL-A (select all), CTRL-C (copy).
In your post #8, select all your code and delete it. Then follow post #7 or type ``` (three backticks) then paste your code, then ``` (three backticks). It should look like Post #7.
And, these are nowhere in your sketch.
Please correct your post and add code tags around your code.
There is a small pencil
below your existing posts.
- click on this pencil ➜ that will let you edit your post.
- Select the part of the text that corresponds to the code
- Click on the
<code/>icon in the toolbar to indicate that it is code - click
Save Edit
(Also make sure to properly indent the code in the IDE before copying and pasting it here. This can be done by pressing ctrlT on a PC or cmdT on a Mac)
