Skip to content

Instantly share code, notes, and snippets.

@BraveTea
BraveTea / Static?
Created May 8, 2018 09:23
What is the whole static variable about? This is code to figure that out and ask for help
public class HelloWorld {
private static final double PI = 3.14;
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World!");
System.out.println(PI);
for (int PI = 0; PI < 5; PI++)
@BraveTea
BraveTea / Code Library : L : Infinity Loop
Created February 10, 2017 10:47
Code Library : L : Infinity Loop
/* an infinity for loop
for ( ; ; )
/* and I also believe below should work. Even so, I think below is what I should use for I can reuse 'i' (e.g. Serial.println(i) in debug)
for (int i = 0; 0 >= 0; i++)
@BraveTea
BraveTea / Code Library : F : Function Values
Created February 3, 2017 22:37
Assigning values to a function()
/* what you need to look for here is the "24" 8' DashedLine(24)
* and combine this with the "int len" in DashedLine(int len)
* those correspond. the 24 is the integer value (called for
* with int len) assigned to the function and thus giving
* "len" in the function the value of 24
*/
void setup() {
Serial.begin(9600);
@BraveTea
BraveTea / Serial Comma Separator + Echo (Delimiter)
Last active January 24, 2017 08:51
Code Library: S : Serial : Comma Separator + Echo (Delimiter)
byte byteRead;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
@BraveTea
BraveTea / Button (switch) State Counter
Created January 23, 2017 15:34
Code Library: B : Button-State-Counter
const int buttonPin = 2;
const int ledPin = 13;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup()
{
pinMode(buttonPin, INPUT);
@BraveTea
BraveTea / Button to Switch
Last active January 24, 2017 08:10
Code Library: B : Button-to-Switch
/* This piece of code changes a button to a switch
* Presses of the button switches between ON and OFF
*/
const int inPin = 2;
const int outPin = 6;
int state = HIGH;
int reading;
int previous = LOW;