The MBED firmware used on the Chipin sorter, developed over 12 weeks for a 3rd year university systems project. Chipin is a token sorter, it sorts tokens by colours and dispenses them to order through an online booking system and card reader. This program interfaces with an FPGA, PC and LCD screen to control the sorter. The sorter has an operation mode where it can process orders when a card is entered into the machine. There is also a maintenance mode where the device responds to maintenance instructions such as 'dispense all'. More information at http://www.ionsystems.uk/

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed

Committer:
IonSystems
Date:
Tue Nov 25 12:59:11 2014 +0000
Revision:
20:6de191ac7ff3
Parent:
19:78d4b78fa736
Child:
22:8f11d1c178ab
Added wait functions for complete signals from FPGA.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IonSystems 6:e64796f1f384 1 #include "mbed.h"
IonSystems 11:06f6e82b40a8 2 //#include "Colour.h"
IonSystems 11:06f6e82b40a8 3 #include "colourProcessing.h"
IonSystems 20:6de191ac7ff3 4 int recycleAmount = 0;
IonSystems 6:e64796f1f384 5 //Setup pins to FPGA
IonSystems 6:e64796f1f384 6 DigitalOut startSort(p5); //A positive edge tells the FPGA to start sorting.
IonSystems 10:8c0696b99692 7 DigitalIn sortComplete(p16);
IonSystems 6:e64796f1f384 8 /*
IonSystems 6:e64796f1f384 9 The command codes for the three sort select bits(ColourBit1 - ColourBit2)
IonSystems 17:6a0bb0ad5bb4 10 See datasheet for furter information
IonSystems 6:e64796f1f384 11 000 Sort red chip
IonSystems 6:e64796f1f384 12 001 Sort green chip
IonSystems 6:e64796f1f384 13 010 Sort blue chip
IonSystems 6:e64796f1f384 14 011 Bin the chip
IonSystems 6:e64796f1f384 15 100 Recycle the chip
IonSystems 6:e64796f1f384 16 101 Nothing
IonSystems 6:e64796f1f384 17 110 Nothing
IonSystems 6:e64796f1f384 18 111 Nothing
IonSystems 6:e64796f1f384 19 */
IonSystems 6:e64796f1f384 20
IonSystems 6:e64796f1f384 21 DigitalOut colourBit1(p6); //The 3 bits below are select bits for the sorter.
IonSystems 6:e64796f1f384 22 DigitalOut colourBit2(p7);
IonSystems 6:e64796f1f384 23 DigitalOut colourBit3(p8);
IonSystems 9:8d78eb55ad5e 24 DigitalOut startDispense(p18); //A positive edge tells the FPGA to start dispensing. p9
IonSystems 6:e64796f1f384 25 /*
IonSystems 6:e64796f1f384 26 00 Dispense red chip
IonSystems 6:e64796f1f384 27 01 Dispense green chip
IonSystems 6:e64796f1f384 28 10 Dispense blue chip
IonSystems 6:e64796f1f384 29 11 Nothing
IonSystems 6:e64796f1f384 30 */
IonSystems 6:e64796f1f384 31
IonSystems 9:8d78eb55ad5e 32 DigitalOut dispenseBit1(p19); //The 2 bits below are select bits for the dispenser.p10
IonSystems 9:8d78eb55ad5e 33 DigitalOut dispenseBit2(p20); //p11
IonSystems 8:b7771391adc9 34
IonSystems 12:814a8fdbb6f7 35 DigitalIn dispenseComplete(p11); //FPGA sets to 1 once complete until another signal is recieved.
IonSystems 10:8c0696b99692 36 DigitalOut select(p15); //0 for control, 1 for maintenance.
IonSystems 10:8c0696b99692 37
IonSystems 12:814a8fdbb6f7 38
IonSystems 19:78d4b78fa736 39 void setMaintenanceSelect(bool bit6, bool bit5, bool bit4, bool bit3, bool bit2, bool bit1)
IonSystems 19:78d4b78fa736 40 {
IonSystems 12:814a8fdbb6f7 41 startSort = bit1;
IonSystems 12:814a8fdbb6f7 42 colourBit1 = bit2;
IonSystems 12:814a8fdbb6f7 43 colourBit2 = bit3;
IonSystems 12:814a8fdbb6f7 44 colourBit3 = bit4;
IonSystems 12:814a8fdbb6f7 45 startDispense = bit5;
IonSystems 12:814a8fdbb6f7 46 dispenseBit1 = bit6;
IonSystems 19:78d4b78fa736 47 }
IonSystems 19:78d4b78fa736 48
IonSystems 19:78d4b78fa736 49 void setMaintenanceStart(bool value)
IonSystems 19:78d4b78fa736 50 {
IonSystems 12:814a8fdbb6f7 51 dispenseBit2 = value;
IonSystems 19:78d4b78fa736 52 }
IonSystems 19:78d4b78fa736 53 void waitForMaintenanceComplete()
IonSystems 19:78d4b78fa736 54 {
IonSystems 19:78d4b78fa736 55 while(!sortComplete) {
IonSystems 14:31ba3e56c788 56 printLCD("Waiting for REC");
IonSystems 12:814a8fdbb6f7 57 wait(0.1);
IonSystems 19:78d4b78fa736 58 }
IonSystems 19:78d4b78fa736 59 }
IonSystems 19:78d4b78fa736 60
IonSystems 19:78d4b78fa736 61 void setDispenseSelect(bool dBit1, bool dBit2)
IonSystems 19:78d4b78fa736 62 {
IonSystems 19:78d4b78fa736 63 dispenseBit1 = dBit1;
IonSystems 19:78d4b78fa736 64 dispenseBit2 = dBit2;
IonSystems 12:814a8fdbb6f7 65 }
IonSystems 19:78d4b78fa736 66
IonSystems 19:78d4b78fa736 67 void setSortSelect(bool sBit1, bool sBit2, bool sBit3)
IonSystems 19:78d4b78fa736 68 {
IonSystems 19:78d4b78fa736 69 colourBit1 = sBit1;
IonSystems 19:78d4b78fa736 70 colourBit2 = sBit2;
IonSystems 19:78d4b78fa736 71 colourBit3 = sBit3;
IonSystems 19:78d4b78fa736 72 }
IonSystems 19:78d4b78fa736 73
IonSystems 19:78d4b78fa736 74 void maintain(StateMachine maintainState)
IonSystems 19:78d4b78fa736 75 {
IonSystems 12:814a8fdbb6f7 76 select = 1; //setting FPGA to maintenance mode.
IonSystems 19:78d4b78fa736 77 setMaintenanceSelect(true,true,true,true,true,true);
IonSystems 19:78d4b78fa736 78 switch(maintainState) {
IonSystems 12:814a8fdbb6f7 79 case RB_LEFT:
IonSystems 12:814a8fdbb6f7 80 setMaintenanceSelect(false,false,false,true,false,true);
IonSystems 19:78d4b78fa736 81 break;
IonSystems 12:814a8fdbb6f7 82 case RB_CENTRE:
IonSystems 12:814a8fdbb6f7 83 setMaintenanceSelect(false,false,false,true,true,false);
IonSystems 19:78d4b78fa736 84 break;
IonSystems 12:814a8fdbb6f7 85 case RB_RIGHT:
IonSystems 12:814a8fdbb6f7 86 setMaintenanceSelect(false,false,false,true,true,true);
IonSystems 19:78d4b78fa736 87 break;
IonSystems 12:814a8fdbb6f7 88 case GO_UP:
IonSystems 12:814a8fdbb6f7 89 setMaintenanceSelect(false,false,true,false,false,false);
IonSystems 19:78d4b78fa736 90 break;
IonSystems 12:814a8fdbb6f7 91 case GO_CENTRE:
IonSystems 12:814a8fdbb6f7 92 setMaintenanceSelect(false,false,true,false,false,true);
IonSystems 19:78d4b78fa736 93 break;
IonSystems 12:814a8fdbb6f7 94 case GO_DOWN:
IonSystems 12:814a8fdbb6f7 95 setMaintenanceSelect(false,false,true,false,true,false);
IonSystems 19:78d4b78fa736 96 break;
IonSystems 12:814a8fdbb6f7 97 case BR_LEFT:
IonSystems 12:814a8fdbb6f7 98 setMaintenanceSelect(false,false,true,false,true,true);
IonSystems 19:78d4b78fa736 99 break;
IonSystems 12:814a8fdbb6f7 100 case BR_RIGHT:
IonSystems 12:814a8fdbb6f7 101 setMaintenanceSelect(false,false,true,true,false,false);
IonSystems 19:78d4b78fa736 102 break;
IonSystems 12:814a8fdbb6f7 103 case R_PUSH:
IonSystems 12:814a8fdbb6f7 104 setMaintenanceSelect(false,false,true,true,false,true);
IonSystems 19:78d4b78fa736 105 break;
IonSystems 14:31ba3e56c788 106 default:
IonSystems 14:31ba3e56c788 107 log("Incorrect maintenance command recieved");
IonSystems 14:31ba3e56c788 108 printLCD("Incorrect maintenance command recieved");
IonSystems 19:78d4b78fa736 109 break;
IonSystems 19:78d4b78fa736 110 }
IonSystems 12:814a8fdbb6f7 111 setMaintenanceStart(true);//Bit 7
IonSystems 12:814a8fdbb6f7 112 waitForMaintenanceComplete();
IonSystems 15:0c5f20e15b6a 113 wait(0.5);
IonSystems 12:814a8fdbb6f7 114 setMaintenanceStart(false);
IonSystems 19:78d4b78fa736 115 }
IonSystems 19:78d4b78fa736 116
IonSystems 19:78d4b78fa736 117 void waitForDispenseComplete()
IonSystems 19:78d4b78fa736 118 {
IonSystems 19:78d4b78fa736 119 //wait(1); //temporary delay
IonSystems 19:78d4b78fa736 120 while(!dispenseComplete) {
IonSystems 19:78d4b78fa736 121 wait(0.2);
IonSystems 19:78d4b78fa736 122 log("Waiting for dispense complete");
IonSystems 19:78d4b78fa736 123 printLCD("Waiting for dispense complete");
IonSystems 12:814a8fdbb6f7 124 }
IonSystems 19:78d4b78fa736 125 wait(0.6);
IonSystems 19:78d4b78fa736 126 log("Complete");
IonSystems 19:78d4b78fa736 127 }
IonSystems 19:78d4b78fa736 128
IonSystems 19:78d4b78fa736 129 void dispense(Colour colour)
IonSystems 19:78d4b78fa736 130 {
IonSystems 12:814a8fdbb6f7 131
IonSystems 19:78d4b78fa736 132 bool validDispense = false;
IonSystems 19:78d4b78fa736 133 select = 0; //Setting to operation mode just in case it has not been set.
IonSystems 19:78d4b78fa736 134 setDispenseSelect(true,true);
IonSystems 19:78d4b78fa736 135 /* A dispense operation can only take place if there are more than zero chips
IonSystems 19:78d4b78fa736 136 */
IonSystems 19:78d4b78fa736 137 switch(colour) {
IonSystems 19:78d4b78fa736 138 case RED:
IonSystems 19:78d4b78fa736 139 if(redAmount > 0 || operationMode == false) {
IonSystems 19:78d4b78fa736 140 log("RED");
IonSystems 19:78d4b78fa736 141 log("Setting dispense bits to 00");
IonSystems 19:78d4b78fa736 142 setDispenseSelect(false,false);
IonSystems 19:78d4b78fa736 143 redAmount--;
IonSystems 19:78d4b78fa736 144 validDispense = true;
IonSystems 19:78d4b78fa736 145 }
IonSystems 10:8c0696b99692 146 break;
IonSystems 19:78d4b78fa736 147 case GREEN:
IonSystems 19:78d4b78fa736 148 if(greenAmount > 0 || operationMode == false) {
IonSystems 19:78d4b78fa736 149 log("GREEN");
IonSystems 19:78d4b78fa736 150 log("Setting dispense bits to 10");
IonSystems 19:78d4b78fa736 151 setDispenseSelect(true,false);
IonSystems 19:78d4b78fa736 152 greenAmount--;
IonSystems 19:78d4b78fa736 153 validDispense = true;
IonSystems 19:78d4b78fa736 154 }
IonSystems 10:8c0696b99692 155 break;
IonSystems 19:78d4b78fa736 156 case BLUE:
IonSystems 19:78d4b78fa736 157 if(blueAmount > 0 || operationMode == false) {
IonSystems 10:8c0696b99692 158 log("BLUE");
IonSystems 10:8c0696b99692 159 log("Setting dispense bits to 01");
IonSystems 19:78d4b78fa736 160 setDispenseSelect(false,true);
IonSystems 12:814a8fdbb6f7 161 blueAmount--;
IonSystems 12:814a8fdbb6f7 162 validDispense = true;
IonSystems 19:78d4b78fa736 163 }
IonSystems 10:8c0696b99692 164 break;
IonSystems 19:78d4b78fa736 165
IonSystems 19:78d4b78fa736 166 }
IonSystems 19:78d4b78fa736 167 writeFile(redAmount,greenAmount,blueAmount);
IonSystems 19:78d4b78fa736 168
IonSystems 19:78d4b78fa736 169 if(validDispense || operationMode == false) {
IonSystems 10:8c0696b99692 170 log("Setting start dispense to true");
IonSystems 10:8c0696b99692 171 startDispense = true; //set the startDispense line high.
IonSystems 19:78d4b78fa736 172
IonSystems 19:78d4b78fa736 173 waitForDispenseComplete();
IonSystems 19:78d4b78fa736 174
IonSystems 10:8c0696b99692 175 log("Setting start dispense to false");
IonSystems 10:8c0696b99692 176 startDispense = false;
IonSystems 19:78d4b78fa736 177
IonSystems 19:78d4b78fa736 178 log("Resetting dispense bits to 11");
IonSystems 19:78d4b78fa736 179 setDispenseSelect(true,true);
IonSystems 19:78d4b78fa736 180
IonSystems 19:78d4b78fa736 181
IonSystems 19:78d4b78fa736 182
IonSystems 10:8c0696b99692 183 printLCD("DISPENSE COMPLETE");
IonSystems 19:78d4b78fa736 184
IonSystems 10:8c0696b99692 185 }
IonSystems 19:78d4b78fa736 186 }
IonSystems 19:78d4b78fa736 187 void dispenseOrder(int r, int g, int b)
IonSystems 19:78d4b78fa736 188 {
IonSystems 19:78d4b78fa736 189 for(int i = r; r >= 0; i--) {
IonSystems 14:31ba3e56c788 190 dispense(RED);
IonSystems 19:78d4b78fa736 191 }
IonSystems 19:78d4b78fa736 192 for(int i = g; i >= 0; i--) {
IonSystems 15:0c5f20e15b6a 193 dispense(GREEN);
IonSystems 19:78d4b78fa736 194 }
IonSystems 19:78d4b78fa736 195 for(int i = g; i >= 0; i--) {
IonSystems 15:0c5f20e15b6a 196 dispense(BLUE);
IonSystems 17:6a0bb0ad5bb4 197 }
IonSystems 19:78d4b78fa736 198 }
IonSystems 19:78d4b78fa736 199
IonSystems 20:6de191ac7ff3 200 void waitForSortComplete()
IonSystems 20:6de191ac7ff3 201 {
IonSystems 20:6de191ac7ff3 202 while(!sortComplete) {
IonSystems 20:6de191ac7ff3 203 wait(0.5);
IonSystems 20:6de191ac7ff3 204 log("Waiting for sort complete");
IonSystems 20:6de191ac7ff3 205 printLCD("Waiting for sort complete");
IonSystems 20:6de191ac7ff3 206 }
IonSystems 20:6de191ac7ff3 207 log("sortComplete signal recieved from FPGA");
IonSystems 20:6de191ac7ff3 208 wait(0.6);
IonSystems 20:6de191ac7ff3 209
IonSystems 20:6de191ac7ff3 210 }
IonSystems 20:6de191ac7ff3 211
IonSystems 20:6de191ac7ff3 212 void lift()
IonSystems 20:6de191ac7ff3 213 {
IonSystems 20:6de191ac7ff3 214 select = 0; //Setting to operation mode just in case it has not been set.
IonSystems 20:6de191ac7ff3 215 setSortSelect(true,true,true);
IonSystems 20:6de191ac7ff3 216 setSortSelect(true,false,true);
IonSystems 20:6de191ac7ff3 217 log("Setting start sort to true, FPGA should begin sorting now");
IonSystems 20:6de191ac7ff3 218 startSort = true; //set the startDispense line high.
IonSystems 20:6de191ac7ff3 219
IonSystems 20:6de191ac7ff3 220
IonSystems 20:6de191ac7ff3 221 //wait(1); //temporary delay
IonSystems 20:6de191ac7ff3 222 waitForSortComplete();
IonSystems 20:6de191ac7ff3 223 log("Setting start sort to false");
IonSystems 20:6de191ac7ff3 224 startSort = false;
IonSystems 20:6de191ac7ff3 225
IonSystems 20:6de191ac7ff3 226 log("Resetting sort bits to 111");
IonSystems 20:6de191ac7ff3 227 setSortSelect(true,true,true);
IonSystems 20:6de191ac7ff3 228 printLCD("LIFT COMPLETE");
IonSystems 20:6de191ac7ff3 229 recycleAmount = 0;
IonSystems 20:6de191ac7ff3 230 }
IonSystems 20:6de191ac7ff3 231
IonSystems 20:6de191ac7ff3 232 void checkRecycleTube(){
IonSystems 20:6de191ac7ff3 233 if(recycleAmount >=5){
IonSystems 20:6de191ac7ff3 234 lift();
IonSystems 20:6de191ac7ff3 235 }
IonSystems 20:6de191ac7ff3 236 }
IonSystems 20:6de191ac7ff3 237
IonSystems 19:78d4b78fa736 238 void recycle()
IonSystems 19:78d4b78fa736 239 {
IonSystems 19:78d4b78fa736 240
IonSystems 19:78d4b78fa736 241 select = 0; //Setting to operation mode just in case it has not been set.
IonSystems 19:78d4b78fa736 242 setSortSelect(true,true,true);
IonSystems 19:78d4b78fa736 243
IonSystems 19:78d4b78fa736 244 log("Recycle");
IonSystems 19:78d4b78fa736 245 log("Setting sort bits to 100");
IonSystems 19:78d4b78fa736 246 setSortSelect(false,false,true);
IonSystems 19:78d4b78fa736 247
IonSystems 19:78d4b78fa736 248 log("Setting start sort to true");
IonSystems 19:78d4b78fa736 249 startSort = true; //set the startDispense line high.
IonSystems 19:78d4b78fa736 250
IonSystems 20:6de191ac7ff3 251 waitForSortComplete();
IonSystems 19:78d4b78fa736 252 log("Setting start sort to false");
IonSystems 19:78d4b78fa736 253 startSort = false;
IonSystems 19:78d4b78fa736 254
IonSystems 19:78d4b78fa736 255 log("Resetting dispense bits to 11");
IonSystems 19:78d4b78fa736 256 setSortSelect(true,true,true);
IonSystems 19:78d4b78fa736 257 printLCD("RECYCLE COMPLETE");
IonSystems 20:6de191ac7ff3 258 recycleAmount++;
IonSystems 20:6de191ac7ff3 259 checkRecycleTube();
IonSystems 19:78d4b78fa736 260 }
IonSystems 19:78d4b78fa736 261
IonSystems 19:78d4b78fa736 262
IonSystems 19:78d4b78fa736 263
IonSystems 19:78d4b78fa736 264 void sort(Colour colour)
IonSystems 19:78d4b78fa736 265 {
IonSystems 19:78d4b78fa736 266 if(colour == NONE) {
IonSystems 19:78d4b78fa736 267 return;
IonSystems 19:78d4b78fa736 268 } else {
IonSystems 19:78d4b78fa736 269
IonSystems 10:8c0696b99692 270 select = 0; //Setting to operation mode just in case it has not been set.
IonSystems 19:78d4b78fa736 271 setSortSelect(true,true,true);
IonSystems 19:78d4b78fa736 272 switch(colour) {
IonSystems 10:8c0696b99692 273 case RED:
IonSystems 19:78d4b78fa736 274 if(redAmount >= tubeSize) {
IonSystems 17:6a0bb0ad5bb4 275 recycle();
IonSystems 17:6a0bb0ad5bb4 276 return;
IonSystems 19:78d4b78fa736 277 }
IonSystems 10:8c0696b99692 278 log("Sort RED");
IonSystems 10:8c0696b99692 279 log("Setting sort bits to 000");
IonSystems 19:78d4b78fa736 280 setSortSelect(false,false,false);
IonSystems 12:814a8fdbb6f7 281 redAmount++;
IonSystems 19:78d4b78fa736 282 break;
IonSystems 10:8c0696b99692 283 case GREEN:
IonSystems 19:78d4b78fa736 284 if(greenAmount >= tubeSize) {
IonSystems 17:6a0bb0ad5bb4 285 recycle();
IonSystems 17:6a0bb0ad5bb4 286 return;
IonSystems 19:78d4b78fa736 287 }
IonSystems 10:8c0696b99692 288 log("Sort GREEN");
IonSystems 10:8c0696b99692 289 log("Setting sort bits to 001");
IonSystems 19:78d4b78fa736 290 setSortSelect(true,false,false);
IonSystems 12:814a8fdbb6f7 291 greenAmount++;
IonSystems 19:78d4b78fa736 292 break;
IonSystems 10:8c0696b99692 293 case BLUE:
IonSystems 19:78d4b78fa736 294 if(blueAmount >= tubeSize) {
IonSystems 17:6a0bb0ad5bb4 295 recycle();
IonSystems 17:6a0bb0ad5bb4 296 return;
IonSystems 19:78d4b78fa736 297 }
IonSystems 10:8c0696b99692 298 log("Sort BLUE");
IonSystems 10:8c0696b99692 299 log("Setting sort bits to 010");
IonSystems 19:78d4b78fa736 300 setSortSelect(false,true,false);
IonSystems 12:814a8fdbb6f7 301 blueAmount++;
IonSystems 19:78d4b78fa736 302 break;
IonSystems 11:06f6e82b40a8 303 case BIN:
IonSystems 11:06f6e82b40a8 304 log("Sort BIN");
IonSystems 11:06f6e82b40a8 305 log("Setting sort bits to 011");
IonSystems 19:78d4b78fa736 306 setSortSelect(true,true,false);
IonSystems 19:78d4b78fa736 307 break;
IonSystems 10:8c0696b99692 308 }
IonSystems 19:78d4b78fa736 309
IonSystems 19:78d4b78fa736 310
IonSystems 10:8c0696b99692 311 log("Setting start sort to true");
IonSystems 10:8c0696b99692 312 startSort = true; //set the startDispense line high.
IonSystems 19:78d4b78fa736 313
IonSystems 19:78d4b78fa736 314
IonSystems 19:78d4b78fa736 315 waitForSortComplete();
IonSystems 10:8c0696b99692 316 log("Setting start sort to false");
IonSystems 19:78d4b78fa736 317 startSort = false;
IonSystems 19:78d4b78fa736 318
IonSystems 19:78d4b78fa736 319 log("Resetting dispense bits to 11");
IonSystems 19:78d4b78fa736 320 setSortSelect(true,true,true);
IonSystems 10:8c0696b99692 321 printLCD("SORT COMPLETE");
IonSystems 12:814a8fdbb6f7 322 writeFile(redAmount,greenAmount,blueAmount);
IonSystems 19:78d4b78fa736 323 }
IonSystems 12:814a8fdbb6f7 324 }
IonSystems 12:814a8fdbb6f7 325
IonSystems 19:78d4b78fa736 326
IonSystems 19:78d4b78fa736 327
IonSystems 19:78d4b78fa736 328 void dispenseAll()
IonSystems 19:78d4b78fa736 329 {
IonSystems 12:814a8fdbb6f7 330 int red = redAmount;
IonSystems 12:814a8fdbb6f7 331 int green = greenAmount;
IonSystems 12:814a8fdbb6f7 332 int blue = blueAmount;
IonSystems 19:78d4b78fa736 333 for(int r = 0; r < red; r++) {
IonSystems 12:814a8fdbb6f7 334 dispense(RED);
IonSystems 12:814a8fdbb6f7 335 wait(0.5);
IonSystems 19:78d4b78fa736 336 }
IonSystems 19:78d4b78fa736 337 redAmount = 0;
IonSystems 19:78d4b78fa736 338
IonSystems 19:78d4b78fa736 339 for(int g = 0; g < green; g++) {
IonSystems 12:814a8fdbb6f7 340 dispense(GREEN);
IonSystems 12:814a8fdbb6f7 341 wait(0.5);
IonSystems 19:78d4b78fa736 342 }
IonSystems 19:78d4b78fa736 343 greenAmount = 0;
IonSystems 19:78d4b78fa736 344
IonSystems 19:78d4b78fa736 345 for(int b = 0; b < blue; b++) {
IonSystems 12:814a8fdbb6f7 346 dispense(BLUE);
IonSystems 12:814a8fdbb6f7 347 wait(0.5);
IonSystems 19:78d4b78fa736 348 }
IonSystems 19:78d4b78fa736 349 blueAmount = 0;
IonSystems 12:814a8fdbb6f7 350 writeFile(redAmount,greenAmount,blueAmount);
IonSystems 19:78d4b78fa736 351 }