Objective

write an application that interfaces with an input &/or output device that you made

Design

I have no background in coding. I will be using arduino to program my board (again) and processing to write my interface application. Plan:

I want to turn on the LED on the board with a mouse klick. Here is just the user interface without talking to the board:


PFont f;
void setup() {
  size(150, 50);
  f = createFont("Arial",48,true); 
}

void draw() {
   background(40, 0, 0);

 
 if (mouseButton == LEFT) {
      fill(255);
 } else if (mouseButton == RIGHT){
         fill(40);
 }
 
 else {
      fill(100);
}
 rect(10, 10, 130, 30); 
 
 fill(10, 210, 230);
ellipse(mouseX, mouseY, 10, 10);
  textAlign(CENTER);
  text("Click for Blinking.",width/2,25); 

}

Porcessing can talk to attinys over serial. You need to import processing.serial.*. When the mouse button is pressed, the processing script sends "HIGH" over the serial port to the attiny board, when the mouse button is not pressed it sends "LOW" (port.write H or L).



import processing.serial.*; 

PFont f;
Serial port;                       // Create object from Serial class
void setup() {
  size(150, 50);
  f = createFont("Arial",48,true); 
 frameRate(10); 
 port = new Serial(this, 9600); 
}

void draw() {
   background(40, 0, 0);

 
 if (mouseButton == LEFT) {
      fill(255);
     port.write('H');               
 } else if (mouseButton == RIGHT){
         fill(40);
 }
 
 else {
       port.write('L');               // send an L otherwise
      fill(100);
}
 rect(10, 10, 130, 30); 
 
 fill(10, 210, 230);
ellipse(mouseX, mouseY, 10, 10);
  textAlign(CENTER);
  text("Click for Blinking.",width/2,25); 

}

The coresponing arduino code reads the status of the serial pin on the board (0,1 pins on the attiny44) and sets the LED pin "HIGH" when it recieves "HIGH" from the serial connection:


#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX



//Define constants:
const int button = 8; //pin with the button, duh
const int LED = 2; //pin with the LED


void setup() {
  // put your setup code here, to run once:
pinMode(button, INPUT_PULLUP);
pinMode(LED, OUTPUT);
Serial.begin(9600);  
}


  
void loop() {
if (Serial.available()) {        // If data is available to read, 
    val = Serial.read();           // read it and store it in val 
  } 
  if (val == 'H') {                // If H was received
    digitalWrite(LED, HIGH);    // turn the LED on 
  } else { 
    digitalWrite(LED, LOW);     // Otherwise turn it OFF
  } 
  delay(100);

}


I will test my code with my blinking board after I come back from thanksgiving! edit: i didn't, sorry!