Components and supplies
Alphanumeric LCD, 16 x 2
Arduino UNO
power supply (12 v)
Breadboard (generic)
TCS3200
Single Turn Potentiometer- 10k ohms
Tools and machines
Solder Wire, Lead Free
Soldering iron (generic)
Project description
Code
untitled
c_cpp
1int OutPut= 10;//naming pin10 of uno as output 2 3 4unsigned int 5 frequency = 0; 6 7 8 9 10 11#include <LiquidCrystal.h> 12 13 14// 15 initialize the library with the numbers of the interface pins 16 17 18LiquidCrystal 19 lcd(8, 9, 7, 11, 12, 13);//RS,EN,D4,D5,D6,D7 20 21 22 23 24 25void setup() 26 27 28{ 29 30 31 32 // set up the LCD's number of columns and rows 33 34 35 lcd.begin(16, 36 2); 37 38 39 40 41 42 pinMode(2, OUTPUT); 43 44 45 pinMode(3, 46 OUTPUT);//PINS 2, 3,4,5 as OUTPUT 47 48 49 pinMode(4, OUTPUT); 50 51 52 53 pinMode(5, OUTPUT); 54 55 56 pinMode(10, INPUT);//PIN 57 10 as input 58 59 60 61 62 63 digitalWrite(2,HIGH); 64 65 66 67 digitalWrite(3,LOW);//setting frequency selection to 20% 68 69 70} 71 72 73void 74 loop() 75 76 77{ 78 79 80 lcd.print("R=");//printing name 81 82 83 84 digitalWrite(4,LOW); 85 86 87 digitalWrite(5,LOW);//setting 88 for RED color sensor 89 90 91 frequency = pulseIn(OutPut, LOW);//reading 92 frequency 93 94 95 lcd.print(frequency);//printing RED color frequency 96 97 98 99 lcd.print(" "); 100 101 102 lcd.setCursor(7, 0);//moving 103 courser to position 7 104 105 106 delay(500); 107 108 109 110 111 112 113 lcd.print("B=");// printing name 114 115 116 digitalWrite(4,LOW); 117 118 119 120 digitalWrite(5,HIGH);// setting for BLUE color sensor 121 122 123 124 frequency = pulseIn(OutPut, LOW);// reading frequency 125 126 127 128 lcd.print(frequency);// printing BLUE color frequency 129 130 131 132 lcd.print(" "); 133 134 135 lcd.setCursor(0, 1); 136 137 138 139 delay(500); 140 141 142 143 144 145 lcd.print("G=");// 146 printing name 147 148 149 digitalWrite(4,HIGH); 150 151 152 digitalWrite(5,HIGH);// 153 setting for GREEN color sensor 154 155 156 frequency = pulseIn(OutPut, 157 LOW);// reading frequency 158 159 160 lcd.print(frequency);// printing 161 GREEN color frequency 162 163 164 lcd.print(" "); 165 166 167 168 lcd.setCursor(0, 0); 169 170 171 delay(500); 172 173 174} 175 176 177
untitled
c_cpp
1int OutPut= 10;//naming pin10 of uno as output 2 3 4unsigned int frequency = 0; 5 6 7 8 9 10#include <LiquidCrystal.h> 11 12 13// initialize the library with the numbers of the interface pins 14 15 16LiquidCrystal lcd(8, 9, 7, 11, 12, 13);//RS,EN,D4,D5,D6,D7 17 18 19 20 21 22void setup() 23 24 25{ 26 27 28 // set up the LCD's number of columns and rows 29 30 31 lcd.begin(16, 2); 32 33 34 35 36 37 pinMode(2, OUTPUT); 38 39 40 pinMode(3, OUTPUT);//PINS 2, 3,4,5 as OUTPUT 41 42 43 pinMode(4, OUTPUT); 44 45 46 pinMode(5, OUTPUT); 47 48 49 pinMode(10, INPUT);//PIN 10 as input 50 51 52 53 54 55 digitalWrite(2,HIGH); 56 57 58 digitalWrite(3,LOW);//setting frequency selection to 20% 59 60 61} 62 63 64void loop() 65 66 67{ 68 69 70 lcd.print("R=");//printing name 71 72 73 digitalWrite(4,LOW); 74 75 76 digitalWrite(5,LOW);//setting for RED color sensor 77 78 79 frequency = pulseIn(OutPut, LOW);//reading frequency 80 81 82 lcd.print(frequency);//printing RED color frequency 83 84 85 lcd.print(" "); 86 87 88 lcd.setCursor(7, 0);//moving courser to position 7 89 90 91 delay(500); 92 93 94 95 96 97 lcd.print("B=");// printing name 98 99 100 digitalWrite(4,LOW); 101 102 103 digitalWrite(5,HIGH);// setting for BLUE color sensor 104 105 106 frequency = pulseIn(OutPut, LOW);// reading frequency 107 108 109 lcd.print(frequency);// printing BLUE color frequency 110 111 112 lcd.print(" "); 113 114 115 lcd.setCursor(0, 1); 116 117 118 delay(500); 119 120 121 122 123 124 lcd.print("G=");// printing name 125 126 127 digitalWrite(4,HIGH); 128 129 130 digitalWrite(5,HIGH);// setting for GREEN color sensor 131 132 133 frequency = pulseIn(OutPut, LOW);// reading frequency 134 135 136 lcd.print(frequency);// printing GREEN color frequency 137 138 139 lcd.print(" "); 140 141 142 lcd.setCursor(0, 0); 143 144 145 delay(500); 146 147 148} 149 150
Downloadable files
color-sensor-circuit_UdbeMwnzfR.gif
color-sensor-circuit_UdbeMwnzfR.gif
Comments
Only logged in users can leave comments