--- title: Hello Neighbour author: Mateus Domingos date: June 5, 2022 --- # Hello Neighbour This part of the text allows space for a practical exploration of the code that runs on the chip. In Aesthetic Programming and Fix My Code, Winnie Soon demonstrates a generous methodology for creating a space for shared understanding. In Fix my Code, they offer a neat definition of what code is: > Basically, code (program code) comprises lines with combinations of characters, words, and numbers. Code is written by humans on a computer – with the help of a keyboard – using so-called programming language. Code contains a set of instructions for the computer of what you want it to do. Every line of code tells the computer to do something, and a document full of lines of code is called a program or script. Each script is designed to carry out a specific job (which might involve a number of subtasks). - Winnie Soon, Fix My Code The object of our study is the Arduino programming language. This has been designed to be accessible and user friendly. The concepts that allow it to function have parallels to other coding languages. The Hello World programme is a common starting point when engaging with a programming language. It is a method of testing a short piece of code for a predictable output. If it doesn't work, it is immediately obvious and allows the hobbyist to make changes before continuing. It uses a process of printing, > In terms of human language, it usually relates to printing on paper, like laser printing. In programming, however, print refers to producing or displaying something on the screen. - Winnie Soon, Fix My Code This is an interesting command to pause on. ((I've been collecting instances of texts (about media materiality) that imagine the page they are printed on - not accounting for the rhizomatic modes of reading now available to a reader)) This designation of printing is clear - we aim to print something legible to the screen - something that communicates outside of the code. This section is titled Hello Neighbourhood as we are placing an extra prediction/hope on the outcome of the command; that is to demonstrate to the people here and now, this temporary assemblage, that the code is running. Arduino expects the hobbyist to be using a piece of hardware of some description and therefore has another take on the Hello World program. This is Blink. Most Arduino based boards have at least one LED built on to them. This is the primary communication tool of the active board. And in fact the command to make the LED function is 'write' - a perhaps more temporal, momentary process than print? And so we'll visit Blink first. File > Example > ESP8266 > Blink Interestingly the blink example retains comments referring to an earlier chip design - resulting in the warning that the module could not print and write at the same time. This is not the case with the ESP8266 module, as the blue LED is connected to a different pin. // ESP8266 Blink by Simon Peter // Blink the blue LED on the ESP-01 module // This example code is in the public domain // The blue LED on the ESP-01 module is connected to GPIO1 // (which is also the TXD pin; so we cannot use //Serial.print() at the same time) // Note that this sketch uses LED_BUILTIN to find the pin with the internal LED void setup() { pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level // but actually the LED is on; this is because // it is active low on the ESP-01) delay(1000); // Wait for a second digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH delay(2000); // Wait for two seconds (to demonstrate the active low LED) } Most of this code is in fact ignored by the chip - it is simply for our understanding. It is helpful marginalia. These are comments and are denoted by the // at the beginning of a line. The Arduino programs usually contain two void sections; setup() and loop(). These are both functions, or blocks of code. The empty parentheses are sometimes filled with the parameters of a function as is demonstrated in the rest of the programme. You should now be able to upload the program to the çhip. If it works, your çhip will begin a steady blink, on, off, on, off - the counting within the çhip, that ticks off the milliseconds from the moment it is switched on, is visible. It is often convenient for the chip to articulate to us beyond the binary encoding of the LED - (although this is a totally valid and intriguing constraint) In the setup() function add these lines; Serial.begin(9600); Serial.print("Hello World"); The first line configures the data rate that the board will use to communicate with the computer. The second line prints the parameter set within the brackets. In this case we will simply write Hello World, within quotes. This could also be a variable or the output of some other part of the program. To view the output from the board, open up the serial monitor within Arduino. Check the monitor is set to the data rate that matches the one we specified (9600). Now when the program is downloaded to the board, after it resets, the serial monitor should receive the Hello World message. For the next stage we are going to increase the complexity of the program. We will draw on several libraries that allow the board to be configured to use the wifi component. This means that with a few commands, we can set up the board to fulfil our Hello Neighbourhood example. /* Modified by ~gg 2022 */ /* Create a WiFi access point and provide a web server on it. */ /* libraries to include. */ #include #include #include /* define network name and password. */ #ifndef APSSID #define APSSID "bruise" #define APPSK "browsing" #endif /* Set these to your desired credentials. */ const char *ssid = APSSID; const char *password = APPSK; /* create the server. */ ESP8266WebServer server(80); /* Go to in a web browser connected to this access point to see it. */ /* Here we define a simple webpage to display to visitors */ const String helloNeighbourhood = "\ \ hello neighbourhood\ \ \ \

hello neighbourhood

\ \ "; void setup() { delay(1000); Serial.begin(115200); Serial.println(); Serial.print("Configuring access point..."); /*You can remove the password parameter if you want the AP to be open.*/ WiFi.softAP(ssid, password); IPAddress myIP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(myIP); server.on("/", handleRoot); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); } void handleRoot() { server.send(200, "text/html", helloNeighbourhood); Serial.println("page served"); } This clearly requires a bit more familiarity with the coding environment, and draws in adjacent coding languages, in the declaration of the html page. However, the program is still built out of the patterns we have seen already. There is an initial declaration of variables and the libraries to be included, followed by the setup and loop functions, and one additional function. The additional function here contains a server.send command that delivers the webpage to someone who joins the wifi and visits the address, Within the main loop we can see that server is simply ready to accept interactions from a client. In the initial setup section we can see the kinds of things that probably aren't too surprising - setting a wifi name and password.