Assignment Description

Week 12 (Interface and Application Programming)

Assignment

Weekly Assignment

  • Group Assignment: Compare as many tool options as possible.
  • Individual Assignments: Write an application that interfaces a user with an input &/or output device that you made.

Group Assignment

Week 12

Coming Soon

Individual Assignments

Week 12

I have an interest in Node-Red

Node-Red is a Flow-Based programming for the internet of thing. The user can program fast just by knowing the logic and not a programing language, but by learning JavaScript the user can take full advantage of Node-Red. Node-RED was built using Node.js. I will dominate Node-Red to build my final project UI with it. I’ll do some tests to see Node-Red’s behavior and dominate it as much as I can. The installation process is really detailed in Node-Red website. The process is similar to what you would do in Linux (open task manager and us commands to install the needed programs). When you finish the installation run the command “node-red” so that your computer turns into a server and generates a local IP address so thar other devices can work in a FLOW or test the UI. I did some testing in Windows but I wouldn’t recommend relying on Windows. After a system update I had some problems executing Node-Red.

I made the decision to setup my Raspberry pi 4 with Linux (Ubuntu MATE). Then you can install every software that you want. Node-Red has a command that you can execute in the terminal. This command will do everything that’s needed to setup everything.





After getting familiar with the program I tried the “debugging” nodes and the “dashboard” nodes. Really easy to setup and play around with one input. The next step is to study how the “Function” nodes to handle more than one input (to use its maximum potential you need to have knowledge with JavaScript).





Now comes a real challenge… Enable serial communication with an MCU. To make this possible I need to sent a string that will execute an action. I needed to work simultaneously with Node-Red and the Arduino IDE to confirm if I was successfully sending the strings and receiving them but the first step was to calibrate the servos. The next code helps with this step.

            #include <Servo.h>
            
            Servo S_1;  // create servo object to control a servo
            
            void setup() {
            
              S_1.attach(11);  // attaches the servo on pin 9 to the servo object
            }
            
            void loop() {
                
              S_1.write(63);   // servo.write(angle)
            
            


We must include the servo.h Arduino Library. The problem that I found was that most of these libraries work with servos with an angle of rotation between 0 - 180. The once I’m using go from 0 - 270. I'm sign the DS3218MG ANNIMOS DS-Model Servo. Something happened with the official website but I have access to the data sheet.

              #include <Servo.h>
              
              Servo S_1;  // create servo object to control a servo
              Servo S_2;
              Servo S_3;
              
              
              char Accessories =0;
              
              
              void setup() {
                Serial.begin(9600);
              
                S_1.attach(11);  
                  S_1.write(0);
              //      delay(1000);
              
              
                S_2.attach(10);  
                  S_2.write(0);
              //      delay(1000);
              
              
                S_3.attach(9);  
                  S_3.write(0);
              //      delay(1000);
              
              
              
              }
              
              void loop() {
              
                if (Serial.available() > 0) {
                  Accessories = Serial.read();
              switch (Accessories) {
                  case '1':  
                    S_1.write(63);
                     break;
              
                  case '2':  
                    S_2.write(59);
                     break;
              
                  case 'C':  
                    S_3.write(65);
                     break;
              
                  case '8':  
                    S_1.write(0);
                    S_2.write(0);
                    S_3.write(0);
                     break;             }
              
              
                }
              }