Skip to content

Instantly share code, notes, and snippets.

#include "LPD8806.h"
#include "SPI.h" // Comment out this line if using Trinket or Gemma
#ifdef __AVR_ATtiny85__
#include <avr/power.h>
#endif
// Example to control LPD8806-based RGB LED Modules in a strip
/*****************************************************************************/
int LED = 13;
int BUTTON = 2;
void setup(){
pinMode(LED,OUTPUT);
pinMode(BUTTON,INPUT);
Serial.begin(9600);
/*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
*/
int trigPin = 11; // Trigger
int echoPin = 12; // Echo
var song;
function setup() {
song = loadSound('assets/song.mp3');
createCanvas(720, 200);
background(255,0,0);
}
function mousePressed() {
if ( song.isPlaying() ) { // .isPlaying() returns a boolean
char letter;
String sym = "AAPL";
void setup(){
}
void draw(){
//In draw method
text("Current key: " + letter, 10, 40);
}
//button
fill(255,0,0);
rect(10,70,100,40);
fill(255,255,255);
words = words + letter;//add this to keyTyped
void keyPressed() {
if (keyCode == 32) {
words = "";
}
public void read(){
String conn = "https://financialmodelingprep.com/api/company/profile/";
conn = conn + sym;
String[] fd = loadStrings(conn);//save info to string array
fd[0] = trim(fd[0].substring(fd[0].indexOf("{")));//grab the part we need
for(int i=0; i<fd.length; i++){
println(fd[i]);//make sure it works.
}
}
//after the for loop add these lines to get the key information about the stock
JSONObject jarr = JSONObject.parse(lines);
JSONObject stock = jarr.getJSONObject(sym);
int price = stock.getInt("Price");
String beta = stock.getString("Beta");
String name = stock.getString("companyName");
println(price + ", " + beta + ", " + name);
String[] lines;
ArrayList<String> pnames = new ArrayList<String>();
ArrayList<Integer> count = new ArrayList<Integer>();
int x = 0;
int y = 380;
int size = 1;
import java.io.FilenameFilter;
int counter = 1;
int pn = 16;//number of puzzle pieces
PImage img; // Declare a variable of type PImage
PImage[][] pieceArray = new PImage[pn][pn];//array of images
int width = 800;
int height = 600;