Delfina Vildosola + Anushka Samant + Kathleen Scopis + Laura Frances
Sunbrella is an autonomous micro bus shelter that tracks the sun to cast the greatest shade coverage keeping commuters in any neighborhood cool all day. At night, embedded street lights automatically turn on and when it rains, the shelter responsively changes position, too. Since Sunbrella tracks the sun, it efficiently charges via solar panels generating excess energy to power inclusive bus hailing features and bus arrival time displays. All in all, Sunbrella is a responsive, minimalist public technology that can deliver transit and environmental equity to all transit riders.
Heat Island Effect is Deadly
Cities are often 1–7°F warmer than outlying areas because of urban heat island effect caused by cities’ built environments, geographies, and intense energy use. Heat generated from vehicle emission, in particular, exacerbates extreme temperatures, particularly in summer months. Public transit must be more accessible than ever to combat rising car ownership rates. Nearly every city in the US offers bus services, but too often it falls short with long wait times. Sunbrella aims to make waiting for the bus safer and more comfortable.
The City of Philadelphia is a paradigmatic heat island, and rising temperatures have deadly consequences for residents.
Low-Income, Non-White Bus Commuters Experience More Heat Stress
Heat stress is not equitably felt across Philadelphia. Neighborhood-level hotspots, known as “intra-urban” heat islands, are caused by the uneven, inequitable spread of heat-absorbing landcovers such as highways and parking lots. Residents of intra-urban heat islands are more likely to experience heat-related illnesses and even death, and in Philadelphia those residents are more likely to be low-income and Black, Hispanic or Asian. Expectedly, these are also areas of high bus commute rates. As of 2022, less than 5% of Philadelphia’s nearly 13,000 bus stops feature a bus shelter, making bus commuting less than desirable on any given hot, cold, rainy, or windy day.
Sunbrella Rollout Strategy
To determine Sunbrella’s prototype site selection, we developed the Sunbrella Equity Index based on three main criteria: heat exposure, bus demand, and streetscape considerations. Click on a map for a more detailed view.
Based on these converging factors, the Sunbrella Equity Index ranks each bus stop for a Sunbrella rollout strategy in Philadelphia.
Inclusive, Responsive and Low-Cost Design
The following pilot prototype is designed for an east-west curb for up to 4-5 riders waiting for the bus at once.
Sunbrella’s sensors are powered by at least 200W of solar PV panels that charge a 12V lithium-ion battery, that powers photoresistors that track light intensity, a motor that tilts the roof panel, and an Arduino Uno as well as a LED display screen and RFID reader to provide assisted ride hailing. With the addition of wireless connectivity, such as wifi or cellular shield, the display screen could also display estimated arrival times.
Sunbrella’s structure features a number of key improvements from the City of Philadelphia’s 2021 Micro-Shelter Pilot, including:
- Integrates a responsive design to optimize shade or rain coverage as well as solar power generation
- Raises the height of the seat from 18” to 36” and chages the seat’s shape so wheelchairs, strollers, or grocery carriages can benefit from the Sunbrella’s protection
- Offers assistance bus hailing where a rider can tap their bus card or app to turn on a light that alerts the bus driver
- Can display readily available real-time bus arrival data
- Casts street light all night rather than only when motion-activated to enhance safety, value to the community at large, and accessibility
For stops with higher ridership and/or a North-South orientation, the Sunbrella’s modular design can be configured to best serve local commuters.
Prototype Demonstration
Next Steps
Sunbrella’s customization options are inspired by the City of Philadelphia’s transit modernization plans that integrate neighborhood-specific artwork. In terms of funding, in order to avoid expensive, large display screens for advertisers, Sunbrella is well-suited for sponsor branding.
References
Heat Island Effect: https://www.epa.gov/heatislands/learn-about-heat-islands
Car-Rich Households are Growing: https://www.bloomberg.com/news/articles/2019-01-07/despite-uber-and-lyft-urban-car-ownership-is-growing
Intra-Urban Heat Islands: https://www.epa.gov/heatislands/heat-islands-and-equity#:~:text=Residents%20of%20intra%2Durban%20heat,trends%20and%20consequences%2C%20and%20solutions.
City of Philadelphia Micro-Shelter Pilot: https://www.phila.gov/media/20210827091725/Micro-bus-shelter-submission.pdf
Technical Tutorial
In the following tutorial, the prototype is built on two modules, or Arduino boards. *All parts indicated with an asterisk were included in the ELEGOO UNO Project Super Starter Kit
Solar Tracker & Motor Module Parts List:
- Arduino UNO R3 Controller Board *
- Elegoo Prototype expansion module (shield and mini breadboard) *
- Servo (SG90)*
- Solar panel (6V)
- Battery charge controller
- XL6009 DC-DC Boost Converter Module
- Rechargeable batteries and dock
- Photoresistors (light dependent resistor – LDR) – 2 pieces *
- Water Detection Sensor with Digital Output
- WS2812B Individually Addressable LEDs
- Various resistors *
- Breadboard jumper wires *
- Female-to-male Dupont wires *
RFID & LCD Display Module Parts List:
- Arduino UNO R3 Controller Board *
- LCD 1602 Module (with pin header) *
- RC522 RFID
- Elegoo Prototype expansion module (shield and mini breadboard) *
- Various resistors *
- Breadboard jumper wires *
- Female-to-male Dupont wires *
- Blue LED *
Wiring Diagrams
- Solar Tracker & Motor Diagram*
- RFID & LCD Display*
- Solar Panel & Rechargeable Battery
*Prototype shield is connected to Arduino Uno board.
Code
Solar Tracker & Motor Module Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
/*Code for a single axis solar tracker with rain override and night light. April 29, 2023 Sunbrella responsive, solar-tracking module This code controls a servo powered, single-axis solar tracker with a water-activated override mechanism and night light. The code also prints basic status information to the serial monitor. Mechanical design & function The solar panel is mounted on an horizontal axis and attached to a servomotor that adjusts the panel’s angle. (When the device is placed in the sunlight the axis supporting the panel should have a North-South orientation, so that by rotating in place it will cause the panel to turn from East to West). LDRs are mounted on opposing panel edges, along the servo’s range of movement. The panel’s range of movement has been constrained, to avoid overrration that would destabilize the model. For a prototype the preferred range is up to 60 degrees, though larger models should probably reduce this. A wiring diagram is also provided for detailed instructions. Parts: Arduino UNO R3 Controller Board * Elegoo Prototype expansion module (shield and mini breadboard) * Servo (SG90)* Solar panel (6V) https://www.amazon.com/Sunnytech-Solar-Module-Polysilicon-Charger/dp/B00HQXWFVQ/ref=sr_1_2_sspa?crid=1IQABLWC0DOZR&keywords=arduino+solar+panel+6v&qid=1679966766&sprefix=arduino+solar+panel+6v%2Caps%2C80&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUE2M0paNk9XNk1JWVUmZW5jcnlwdGVkSWQ9QTA3OTU4NzgxT1RCMFhJVzJXNkkzJmVuY3J5cHRlZEFkSWQ9QTA1OTQzODFJU0c2WTRZR0dYRVQmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl Battery charge controller https://www.amazon.com/Makerfocus-Charging-Lithium-Battery-Protection/dp/B071RG4YWM/ref=as_li_ss_tl?dchild=1&keywords=TP4056&qid=1593227138&sr=8-3&linkCode=ll1&tag=circbasi-20&linkId=957634db00eebaef6169a13464f34088&language=en_US XL6009 DC-DC Boost Converter Module https://www.amazon.com/gp/product/B07L64GJ42/ref=ppx_yo_dt_b_asin_title_o01_s01?ie=UTF8&psc=1 Rechargable batteries and dock Photoresistors (light dependent resistor – LDR) – 2 pieces * Water Detection Sensor with Digital Output https://www.adafruit.com/product/4965 WS2812B Individually Addressable LEDs Various resistors * Breadboard jumper wires * Female-to-male Dupont wires * * Parts indicated with an asterisk came in the ELEGOO UNO Project Super Starter Kit. All other parts were acquired separately. Wiring: (following traditional color coding with red wires for 5V and black for ground is encouraged to facilitate trouble shooting and to avoid burning components, where possible select distinctive colors for Pin wiring.) Servo: Positive (red) to 5V Pulse (orange) to Pin 6 Negative/ ground (black) to ground Panel: Solder the wiring connecting positive and negative terminals of the solar panel to the respective input terminals of the battery charge controller and repeat accordingly for the Boost Converter Module. Check the dedicated tutorial for further details. https://www.sensingthecity.com/using-a-solar-cell-and-rechargeable-battery-to-power-a-servo-motor/ Connect boost converter module to Pin A3 Photoresistors For each photoresistor use Dupont wires to connect 1 terminal to 5V and the other to the breadboard, lining up a resistor, a wire to analogue Pins A0 or A1 respectively and a ground connection. Water sensor: Positive (red) to 5V Pulse (orange) to PinA2 Negative/ ground (black) to ground LED strip: Positive (red) to 5V Pulse (green) to 330 Ohms resistor and to Pin 4 Negative/ ground (black) to ground Board to battery via DC or to laptop. Software: Code developed on Arduino IDE 2.0.3 with some troubleshooting assistance from ChatGPT Mar 23 Version. Libraries used: Servo.h version 1.1.8 FastLED version 3.5.0 Sources and credits: Concepts and coding for the use of the solar panel and rechargable batteries drawn from: - Hannah Bonestroo’s tutorial, "Powering Arduino Uno with Solar Cell" published on April 3, 2022; available at https://www.sensingthecity.com/powering-arduino-uno-with-solar-cell/ - "XL6009 - Voltage Adjustable DC-DC (5v-35v) Boost Converter Module | Step Up Voltage | POWER GEN" by POWER GEN, published on December 16, 2019; available at https://www.youtube.com/watch?v=Q5bi9-oQezE - "How to make a solar tracking system using Arduino | step by step" by SriTu Hobby, published on February 15, 2022; available at https://www.youtube.com/watch?v=YC4kIGQYld4 The solar tracking code is largely based on: - "Arduino Solar Tracker" by Aboubakr_Elhammoumi and motahhir, published on April 10, 2020; available at https://projecthub.arduino.cc/Aboubakr_Elhammoumi/77347b69-2ade-4a44-b724-3bb91e954188 - "How to Make Solar Tracker with Arduino Uno R3", by ICV Creative, published on April 7, 2021; available at https://www.youtube.com/watch?v=dP6gO19t2pk Water sensor code is largely based on: - "Arduino- Water Sensor" on Arduino Get Started, last accessed April 29, 2023 available at https://arduinogetstarted.com/tutorials/arduino-water-sensor - ELEGOO Super Starter Kit for UNO V1.0.2022.08.04 Lesson 9 Servo code, downloadable at https://www.elegoo.com/blogs/arduino-projects/elegoo-uno-project-super-starter-kit-tutorial LED strip code adapted from: "How To Control WS2812B Individually Addressable LEDs using Arduino" by Dejan; available at https://howtomechatronics.com/tutorials/arduino/how-to-control-ws2812b-individually-addressable-leds-using-arduino/ Project: This is the code for one of two arduino modules used in the Sunbrella prototype, as presented on April 25, 2023. The Sunbrella is a responsive bus shelter, and was conceived as our final project for the course "Sensing the City" taught by Professor Allison Lassiter for students in University of Pennsylvania’s Department of City and Regional Planning. The Sunbrella team: Laura Frances, Anushka Samant, Kathleen Scopis, and Delfina Vildosola. Final code compiled and reviewed by Delfina Vildosola. */ #include <Servo.h> // Servo motor library Servo servo_rightleft; // Declare servo //Initialize variables for servo code int ldrright = A0; // Right LDR pin int ldrleft = A1; // Left LDR pin int photoSensorValue = 0; int numReadings = 4; // Number of readings to average int topl = 0; int topr = 0; int motorPin = 8; // Set motor pin int servo_threshold = 3; // Measurement sensitivity, a smaller value will mean the movement will be more easily triggered. //If the velue is too small the model will be more "twitchy" and move a lot more. int currentPos = servo_rightleft.read(); // Get the current position of the servo int flat_pos = 100; // Set the desired flat position int waterSensorPin = A2; // Analog pin for water sensor // Define the threshold values for triggering the motor action and adjusting the motor position int rainThreshold = 500; // When the water sensor readings exceed this value the override will be triggered int sunThreshold = 50; // This value determines the minimum sunlight needed for the solar tracker mechanism to be activated int nightThreshold = 50; // This value determines the sensitivity for triggering the night light (LED strip) #include <FastLED.h> // Library for night light LED strip #define LED_PIN 12 // Define Pin for night light LED strip #define NUM_LEDS 5 // Define the number of individual LEDs in teh strip that will be initiated CRGB leds[NUM_LEDS]; void setup() { //pinMode(NIGHTledPin, OUTPUT); FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); pinMode(motorPin, OUTPUT); // Initialize the digital pin for the motor Serial.begin(9600); // Set up the serial communication for debugging, opens serial port, sets data rate to 9600 bps Serial.println("CLEARDATA"); // Clear any data that’s been place in already Serial.print("servo_threshold: "); Serial.print(servo_threshold); // Print servo Threshold Serial.print(" | rainThreshold: "); Serial.print(rainThreshold); // Print Rain Threshold Serial.print(" | sunThreshold: "); Serial.print(sunThreshold); // Print Sunlight Threshold Serial.print(" | nightThreshold: "); Serial.println(nightThreshold); // Print Sunlight Threshold servo_rightleft.attach(motorPin); // Servo motor for right-left movement // Reset the servo position for (int pos = currentPos; pos <= flat_pos; pos++) { servo_rightleft.write(pos); // Move the servo to the next position delay(500); // Adjust this delay to make the movement slower or faster } } void automaticsolartracker() { // This section of the code includes the specific loop for the solar tracker. //This function can then be called in the main loop as needed depending on whether different conditions are met. // Capturing analog values of each LDR topr = analogRead(ldrright); // Capture analog value of right LDR topl = analogRead(ldrleft); // Capture analog value of left LDR int diffazi = topl - topr; // Get the difference in average between the right and left LDRs // Left-right movement of solar tracker - other trackers include a second axis of movement to adjust the North-South angle of the panel if (abs(diffazi) >= servo_threshold) { // Change position only if light intensity difference is bigger then the threshold_value int targetPos = 0; if (diffazi > 0) { targetPos = -20; // Sets a limit on the range of movement in one direction } else { targetPos = 20; // Sets a limit on the range of movement in the opposite direction } int currentPos = servo_rightleft.read(); // Redas current servo position int increment = (targetPos - currentPos) / 100; // Determines the movement if (increment == 0) { increment = 1; } for (int i = 0; i < 2; i++) { // Movement graduation currentPos += increment; servo_rightleft.write(currentPos); // Move the servo to the next position delay(500); // Adjust this delay to make the movement slower or faster } } } void loop() { int waterSensorValue = analogRead(waterSensorPin); // Read the value from the water sensor and photosensor int reading = 0; for (int i = 0; i < numReadings; i++) { // Read the analog value from the two LDRs and add them up reading += analogRead(ldrright); reading += analogRead(ldrleft); } photoSensorValue = reading / (numReadings * 2); // Calculate the average int currentPos = servo_rightleft.read(); topr = analogRead(ldrright); // Capture analog value of right LDR topl = analogRead(ldrleft); // Capture analog value of left LDR // Print the sensor values to the serial monitor for debugging & monitoring Serial.print("Water Sensor: "); Serial.print(waterSensorValue); Serial.print(" | Photo Sensor average: "); Serial.println(photoSensorValue); delay (500); if (waterSensorValue > rainThreshold) { // Check if it's raining based on the water sensor value digitalWrite(motorPin, HIGH); // Trigger the motor action by setting the motor pin to high for (int pos = currentPos; pos <= flat_pos; pos++) { servo_rightleft.write(flat_pos); // Move the servo to the next position delay(10); // Adjust this delay to make the movement slower or faster } } // Check if it's not raining and the sun intensity is high based on the photosensor value else if (waterSensorValue <= rainThreshold && photoSensorValue > sunThreshold) { float voltage = analogRead(A0) * 5.0 / 1023.0; // Read the voltage from the boost converter. if (voltage > 12.0) { // If the voltage is less than 12V, turn off the motor. digitalWrite(motorPin, LOW); } else { // If the voltage is greater than or equal to 12V, turn on the motor. digitalWrite(motorPin, HIGH); // Activate the roof movement by setting the motor pin to high. automaticsolartracker(); // Call automatic solar tracker function, which will determine the movement required } } else { // If conditions are not met, stop the motor action by setting the motor pin to low digitalWrite(motorPin, LOW); } Serial.begin(9600); // Set up the serial communication for debugging & monitoring, opens serial port, sets data rate to 9600 bps Serial.print("TRACKER > topr: "); Serial.print(topr); // Print right LDR reading Serial.print(" | topl: "); Serial.print(topl); // Print right LDR reading Serial.print(" | currentPos: "); Serial.println(currentPos); // Print currewnt servo position delay(500); // Wait for a short delay before repeating the loop { // Capturing analog values of each LDR topr = analogRead(ldrright); // Capture analog value of right LDR topl = analogRead(ldrleft); // Capture analog value of left LDR int reading = topr + topl; if (photoSensorValue <= nightThreshold) { // Set condition for activation of night light Serial.println("LED_PIN, HIGH"); // Activate night light // The following lines of code determine the color and intensity of each of the individual LEDs in the strip. // Given these are RGB LEDs, it is possible to program different colors, intensities and/or effects such as a specific sequence. // Enjoy customizing! leds[0] = CRGB(255, 255, 255); // white FastLED.show(); leds[1] = CRGB(255, 255, 255); // white FastLED.show(); leds[2] = CRGB(255, 255, 255); // white FastLED.show(); leds[3] = CRGB(255, 255, 255); // white FastLED.show(); leds[4] = CRGB(255, 255, 255); // white FastLED.show(); /* leds[5] = CRGB(255, 255, 255); // white FastLED.show(); leds[6] = CRGB(255, 255, 255); // white FastLED.show(); leds[7] = CRGB(255, 255, 255); // white FastLED.show(); leds[8] = CRGB(255, 255, 255); // white FastLED.show(); leds[9] = CRGB(255, 255, 255); // white FastLED.show(); leds[10] = CRGB(255, 255, 255); // white FastLED.show(); leds[11] = CRGB(255, 255, 255); // white FastLED.show(); leds[12] = CRGB(255, 255, 255); // white FastLED.show(); */ } else { digitalWrite(LED_PIN, LOW); Serial.println("LED_PIN, LOW"); leds[0] = CRGB(0, 0, 0); // white FastLED.show(); leds[1] = CRGB(0, 0, 0); // white FastLED.show(); leds[2] = CRGB(0, 0, 0); // white FastLED.show(); leds[3] = CRGB(0, 0, 0); // white FastLED.show(); leds[4] = CRGB(0, 0, 0); // white FastLED.show(); /* leds[5] = CRGB(0, 0, 0); // white FastLED.show(); leds[6] = CRGB(0, 0, 0); // white FastLED.show(); leds[7] = CRGB(0, 0, 0); // white FastLED.show(); leds[8] = CRGB(0, 0, 0); // white FastLED.show(); leds[9] = CRGB(0, 0, 0); // white FastLED.show(); leds[10] = CRGB(0, 0, 0); // white FastLED.show(); leds[11] = CRGB(0, 0, 0); // white FastLED.show(); leds[12] = CRGB(0, 0, 0); // white FastLED.show(); */ } } } |
RFID & LCD Display Module Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
/*Code for RFID reader and 16x2 LCD display. April 29, 2023 Sunbrella RFID + LCD module + LED light This code controls an RFID reader and displays a series of messages in an LCD display: - as a default it displays instructions to tap an RFID card to the reader. - when a card is tapped it displays a sequence of messages while simultaneously activating a light mounted on the prototype. The code also prints basic status information to the serial monitor. A wiring diagram is also provided for detailed instructions, seeing as there are contradictory diagrams available online which presented one of the greatest challenges in the development of this module. Parts: Arduino UNO R3 Controller Board LCD 1602 Module (with pin header) RC522 RFID Elegoo Prototype expansion module (shield and mini breadboard) Various resistors Breadboard jumper wires Female-to-male Dupont wires Blue LED *All parts with the exception of the RFID reader came in the ELEGOO UNO Project Super Starter Kit Wiring: RFID sensor: SDA to Pin 10 SCK to Pin 13 MOSI to Pin 11 MISO to Pin 12 IRQ - no wiring GND to ground RST to Pin 9 3.3V to 3.3V Pin LCD display: VSS to ground VDD to 5V V0 to resistors, then ground RS to Pin 6 RW to ground E to Pin 7 D0 to D3 - no wiring D4 to Pin 5 D5 to Pin 4 D6 to Pin 3 D7 to Pin 2 A to 220 Ohms resistor then 5 V K to ground Blue LED to Pin 8 & ground Board to battery via DC or to laptop. Software: Code developed on Arduino IDE 2.0.3 with some troubleshooting assistance from ChatGPT Mar 23 Version. Libraries used: SPI at version 1.0 MFRC522 at version 1.4.9 LiquidCrystal at version 1.0.7 Sources and credits: This code is largely based on code by Technic 1510 titled "RFID Reader With LCD 1602" available at https://projecthub.arduino.cc/Techinc1510/5227d7ed-090a-4259-9361-3efce5ff58ab Credit also goes to Paul_B for his comments on the Arduino forums addressing frequent wiring issues https://forum.arduino.cc/t/1602-lcd-not-working/629671 Coding for LED adapted from the examples provided by the Arduino IDE. Project: This is the code for one of two arduino modules used in the Sunbrella 1.2 prototype, as presented on April 25, 2023. The Sunbrella is a responsive bus shelter, and was conceived as our final project for the course "Sensing the City" taught by Professor Allison Lassiter for students in University of Pennsylvania’s Department of City and Regional Planning. The Sunbrella team: Laura Frances, Anushka Samant, Kathleen Scopis, and Delfina Vildosola. Final code compiled and reviewed by Delfina Vildosola. */ #include <SPI.h> #include <MFRC522.h> #include <LiquidCrystal.h> //RFID reader pins #define SS_PIN 10 #define RST_PIN 9 #define LED_BUILTIN 8 // Set LED Pin //LCD display pins MFRC522 mfrc522(SS_PIN, RST_PIN); LiquidCrystal lcd(6, 7, 5, 4, 3, 2); void setup() { SPI.begin(); // Initiate RFID reader mfrc522.PCD_Init(); lcd.begin(16, 2); // Initiate LCD display at 16x2 Serial.begin(9600); // Serial communication with the PC mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details pinMode(LED_BUILTIN, OUTPUT); // Initiate digital pin LED_BUILTIN as an output. Serial.println(F("Welcome to Sunbrella! Please stand by")); // Print initial message to serial monitor } void loop() { if ( ! mfrc522.PICC_IsNewCardPresent()) // If statement for default - no RFID card tapped { lcd.clear(); // Set inital LCD display message when no card is tapped lcd.setCursor(0, 0); // LCD display message 1 - set cursor on top line for a 2 line message lcd.print("Please tap your "); // LCD display message 1 - text for top line (use 16 characters) lcd.setCursor(0, 1); // LCD display message 1 - set cursor on bottom line for a 2 line message lcd.print(" SEPTA bus card "); // LCD display message 1 - text for bottom line (use 16 characters) delay(1000); return; } if ( ! mfrc522.PICC_ReadCardSerial()) // If statement for RFID card detected Serial.println("Bus hailed, activating LED and LCD response"); // Set serial monitor message in response to card being tapped. In the future this may be edited to log additional information. digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on (HIGH is the voltage level) lcd.clear(); lcd.print("*~ BUS HAILED ~*"); // Set LCD display message 2 in response to card being tapped (no need to set the cursor position as this is a 1 line message) delay(5000); // Wait for 5 seconds - time for message to be read by user lcd.clear(); lcd.setCursor(0, 0); // LCD display message 3 - set cursor on top line for a 2 line message lcd.print("Please wait. Bus"); // LCD display message 3 - text for top line (use 16 characters) lcd.setCursor(0, 1); // LCD display message 3 - set cursor on bottom line for a 2 line message lcd.print("arrives in 3 min"); // LCD display message 3 - text for bottom line (use 16 characters) delay(5000); // Wait for 5 seconds - time for message to be read by user lcd.setCursor(0, 0); // LCD display message 4 - set cursor on top line for a 2 line message lcd.print("~ Thank you for "); // LCD display message 4 - text for top line (use 16 characters) lcd.setCursor(0, 1); // LCD display message 4 - set cursor on bottom line for a 2 line message lcd.print("riding SEPTA :D "); // LCD display message 4 - text for bottom line (use 16 characters) delay(5000); // Wait for 5 seconds - time for message to be read by user lcd.clear(); // Reset the LCD and start over delay (3000); digitalWrite(LED_BUILTIN, LOW); // Turn the LED off by making the voltage LOW - in the future a signal indicating the bus has arrived (eg: via wifi) should trigger the deactivation of the LED light } |