Code Dump
Single Servo Serial Position
  1. // Serial to Servo Position
  2. #include "Servo.h"
  3. Servo servo;
  4. int pos;
  5. void setup() {
  6. servo.attach(6);
  7. Serial.begin(9600);
  8. servo.write(90);
  9. }
  10. void loop() {
  11. if (Serial.available() > 0) {
  12. pos = Serial.parseInt();
  13. Serial.println(pos);
  14. servo.write(pos);
  15. delay(100);
  16. }
  17. }

Multi-Servo Serial Position (VarSpeedServo)
  1. // Multi Serial to VarSpeedServo
  2. // https://github.com/netlabtoolkit/VarSpeedServo
  3. /*
  4. Type: Servo No. + Position + . + Speed
  5. Keypad Friendly Position and Speed Testing
  6. Example: 290.120 (Servo 2 Position 90 Speed 120)
  7. 10 to 1180 + .0 to .255 Speed for Servo 1
  8. */
  9. #include "VarSpeedServo.h"
  10. // Name Servos
  11. VarSpeedServo one;
  12. VarSpeedServo two;
  13. VarSpeedServo three;
  14. VarSpeedServo four;
  15. VarSpeedServo five;
  16. // Set Values
  17. String input;
  18. String also;
  19. String then;
  20. int also_int;
  21. int then_pos;
  22. int then_int;
  23. // Default Position and Speed
  24. const int start = 90;
  25. const int set_speed = 50;
  26. void setup() {
  27. Serial.begin(9600);
  28. // Assign Pins
  29. one.attach(2);
  30. two.attach(3);
  31. three.attach(4);
  32. four.attach(5);
  33. five.attach(6);
  34. // Default Position and Speed
  35. one.write(start, set_speed, true);
  36. two.write(start, set_speed, true);
  37. three.write(start, set_speed, true);
  38. four.write(start, set_speed, true);
  39. five.write(start, set_speed, true);
  40. }
  41. void loop() {
  42. if (Serial.available() > 0)
  43. {
  44. // Assign Strings
  45. input = Serial.readString();
  46. also = input;
  47. then = also;
  48. // Get Servo Number
  49. input.remove(1);
  50. // Get Position
  51. also.remove(0, 1);
  52. also_int = also.toInt();
  53. // Get Speed
  54. then_pos = then.indexOf('.');
  55. then_pos = then_pos + 1;
  56. then = then.substring(then_pos);
  57. then_int = then.toInt();
  58. // Print Results
  59. Serial.print(input);
  60. Serial.print(" ");
  61. Serial.print(also_int);
  62. Serial.print(" ");
  63. Serial.println(then_int);
  64. // Run Results
  65. if (input == "1") {
  66. one.write(also_int, then_int, true);
  67. } else if (input == "2") {
  68. two.write(also_int, then_int, true);
  69. } else if (input == "3") {
  70. three.write(also_int, then_int, true);
  71. } else if (input == "4") {
  72. four.write(also_int, then_int, true);
  73. } else if (input == "5") {
  74. five.write(also_int, then_int, true);
  75. }
  76. delay(10);
  77. }
  78. }

Fastled Random Order Block Segment
  1. #include "FastLED.h"
  2. #define NUM_LEDS 200
  3. CRGB leds[NUM_LEDS];
  4. #define PIN 9
  5. int v;
  6. int rd;
  7. int gn;
  8. int bl;
  9. int w;
  10. int start;
  11. int fin;
  12. int state;
  13. int last_state;
  14. // int pot_read;
  15. const int pos_num = 16;
  16. int pos_array[pos_num];
  17. void setup() {
  18. FastLED.addLeds< WS2812B, PIN, GRB >(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  19. }
  20. void loop() {
  21. blocks(0, 0, 255);
  22. blocks(0, 0, 0);
  23. }
  24. void blocks(int rd, int gn, int bl) {
  25. randomizelist();
  26. for (w = 0; w < pos_num; w++) {
  27. start = pos_array[w];
  28. start = start * 15;
  29. fin = start + 15;
  30. for (v = start; v < fin; v++) {
  31. setPixel(v, rd, gn, bl);
  32. }
  33. showStrip();
  34. // escape/change function with pot (optional)
  35. // pot_read = analogRead(A0);
  36. // state = map(pot_read, 0, 1023, 1, 10);
  37. // if (state != last_state) {
  38. // return;
  39. // }
  40. delay(750);
  41. }
  42. }
  43. void randomizelist() {
  44. unsigned char chosen[pos_num];
  45. unsigned char index_pt, log_pt;
  46. for (index_pt = 0; index_pt < pos_num; index_pt++)
  47. chosen[index_pt] = 0;
  48. randomSeed(analogRead(A0));
  49. for (index_pt = 0; index_pt < pos_num; index_pt++) {
  50. int r = random(pos_num - index_pt);
  51. for (log_pt = 0; log_pt <= r; log_pt++) {
  52. r += chosen[log_pt];
  53. }
  54. chosen[r] = 1;
  55. pos_array[index_pt] = r;
  56. }
  57. }
  58. void showStrip() {
  59. #ifdef ADAFRUIT_NEOPIXEL_H
  60. // NeoPixel
  61. strip.show();
  62. #endif
  63. #ifndef ADAFRUIT_NEOPIXEL_H
  64. // FastLED
  65. FastLED.show();
  66. #endif
  67. }
  68. void setPixel(int Pixel, byte red, byte green, byte blue) {
  69. #ifdef ADAFRUIT_NEOPIXEL_H
  70. // NeoPixel
  71. strip.setPixelColor(Pixel, strip.Color(red, green, blue));
  72. #endif
  73. #ifndef ADAFRUIT_NEOPIXEL_H
  74. // FastLED
  75. leds[Pixel].r = red;
  76. leds[Pixel].g = green;
  77. leds[Pixel].b = blue;
  78. #endif
  79. }
  80. void setAll(byte red, byte green, byte blue) {
  81. for (int i = 0; i < NUM_LEDS; i++ ) {
  82. setPixel(i, red, green, blue);
  83. }
  84. showStrip();
  85. }

Lightning Code
  1. // Lighting Cloud
  2. // James Bruce
  3. #include "FastLED.h"
  4. #define NUM_LEDS 6
  5. #define DATA_PIN 9
  6. enum Mode {CLOUD, ACID, OFF, ON, RED, GREEN, BLUE, FADE};
  7. Mode mode = CLOUD;
  8. Mode lastMode = CLOUD;
  9. int fade_h;
  10. int fade_direction = 1;
  11. CRGB leds[NUM_LEDS];
  12. void setup() {
  13. FastLED.addLeds< WS2812B, DATA_PIN, GRB >(leds, NUM_LEDS);
  14. Serial.begin(9600);
  15. }
  16. void loop() {
  17. constant_lightning();
  18. }
  19. void single_colour(int H) {
  20. for (int i = 0; i < NUM_LEDS; i++) {
  21. leds[i] = CHSV( H, 255, 255);
  22. }
  23. if (lastMode != mode) {
  24. FastLED.show();
  25. lastMode = mode;
  26. }
  27. delay(50);
  28. }
  29. void colour_fade() {
  30. for (int i = 0; i < NUM_LEDS; i++) {
  31. leds[i] = CHSV( fade_h, 255, 255);
  32. }
  33. if (fade_h > 254) {
  34. fade_direction = -1;
  35. }
  36. else if (fade_h < 0) {
  37. fade_direction = 1;
  38. }
  39. fade_h += fade_direction;
  40. FastLED.show();
  41. delay(100);
  42. }
  43. void reset() {
  44. for (int i = 0; i < NUM_LEDS; i++) {
  45. leds[i] = CHSV( 0, 0, 0);
  46. }
  47. FastLED.show();
  48. }
  49. void acid_cloud() {
  50. for (int i = 0; i < NUM_LEDS; i++) {
  51. if (random(0, 100) > 90) {
  52. leds[i] = CHSV( random(0, 255), 255, 255);
  53. }
  54. else {
  55. leds[i] = CHSV(0, 0, 0);
  56. }
  57. }
  58. FastLED.show();
  59. delay(random(5, 100));
  60. reset();
  61. //}
  62. }
  63. void rolling() {
  64. for (int r = 0; r < random(2, 10); r++) {
  65. for (int i = 0; i < NUM_LEDS; i++) {
  66. if (random(0, 100) > 90) {
  67. leds[i] = CHSV( 0, 0, 255);
  68. }
  69. else {
  70. leds[i] = CHSV(0, 0, 0);
  71. }
  72. }
  73. FastLED.show();
  74. delay(random(5, 100));
  75. reset();
  76. }
  77. }
  78. void crack() {
  79. for (int i = 0; i < NUM_LEDS; i++) {
  80. leds[i] = CHSV( 0, 0, 255);
  81. }
  82. FastLED.show();
  83. delay(random(10, 100));
  84. reset();
  85. }
  86. void thunderburst() {
  87. int rs1 = random(0, NUM_LEDS / 2);
  88. int rl1 = random(10, 20);
  89. int rs2 = random(rs1 + rl1, NUM_LEDS);
  90. int rl2 = random(10, 20);
  91. for (int r = 0; r < random(3, 6); r++) {
  92. for (int i = 0; i < rl1; i++) {
  93. leds[i + rs1] = CHSV( 0, 0, 255);
  94. }
  95. if (rs2 + rl2 < NUM_LEDS) {
  96. for (int i = 0; i < rl2; i++) {
  97. leds[i + rs2] = CHSV( 0, 0, 255);
  98. }
  99. }
  100. FastLED.show();
  101. delay(random(10, 50));
  102. reset();
  103. delay(random(10, 50));
  104. }
  105. }
  106. void constant_lightning() {
  107. switch (random(1, 4)) {
  108. case 1:
  109. thunderburst();
  110. delay(random(10, 500));
  111. break;
  112. case 2:
  113. rolling();
  114. break;
  115. case 3:
  116. crack();
  117. delay(random(50, 250));
  118. break;
  119. case 4:
  120. acid_cloud();
  121. break;
  122. }
  123. }

Arduino Potentiometer Timer
  1. #include "TM1637Display.h"
  2. #define CLK 9
  3. #define DIO 10
  4. TM1637Display display = TM1637Display(CLK, DIO);
  5. #include "FastLED.h"
  6. #define NUM_LEDS 2
  7. #define LED_TYPE WS2812B
  8. #define COLOR_ORDER GRB
  9. CRGB leds[NUM_LEDS];
  10. const int NEO = 3;
  11. int num;
  12. int num_pre;
  13. int num_set;
  14. int num_dis;
  15. int num_out;
  16. int num_sto;
  17. int col;
  18. int smooth;
  19. int stor;
  20. const int time_pot = A5;
  21. const int button = 6;
  22. int state;
  23. int p;
  24. void setup() {
  25. Serial.begin(9600);
  26. display.clear();
  27. display.setBrightness(2);
  28. FastLED.addLeds< LED_TYPE, NEO, COLOR_ORDER >(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  29. pixel(0, 0, 255);
  30. pinMode(button, INPUT_PULLUP);
  31. }
  32. void loop() {
  33. if (state == 0) {
  34. pixel(0, 0, 255);
  35. // select minutes 1-60
  36. // wait for button
  37. while (digitalRead(button) == HIGH) {
  38. // smooth attempt uno
  39. stor = 0;
  40. for (smooth = 0; smooth < 10; smooth++) {
  41. num = analogRead(time_pot);
  42. stor = stor + num;
  43. }
  44. stor = stor / 10;
  45. num_pre = map(stor, 1023, 0, 1, 60);
  46. num_set = round(num_pre);
  47. num_set = num_set * 100;
  48. // smooth attempt dos
  49. if (num_set != num_sto) {
  50. display.showNumberDecEx(num_set, 0b01000000, false, 4, 0);
  51. }
  52. num_sto = num_set;
  53. }
  54. state = 1;
  55. pixel(0, 0, 0);
  56. } else if (state == 1) {
  57. // minute count down
  58. for (num_out = num_pre; num_out > 1; num_out--) {
  59. num_dis = num_out * 100;
  60. display.showNumberDecEx(num_dis, 0b01000000, false, 4, 0);
  61. delay(60000);
  62. }
  63. state = 2;
  64. } else if (state == 2) {
  65. // 60 second count down
  66. for (num_dis = 60; num_dis > 0; num_dis--) {
  67. display.showNumberDecEx(num_dis, 0b01000000, false, 4, 0);
  68. delay(1000);
  69. }
  70. state = 3;
  71. } else if (state == 3) {
  72. // warning
  73. display.clear();
  74. // wait for button
  75. while (digitalRead(button) == HIGH) {
  76. pixel(255, 0, 0);
  77. delay(300);
  78. pixel(0, 0, 0);
  79. delay(300);
  80. }
  81. // sort-a debounce
  82. pixel(0, 255, 0);
  83. display.clear();
  84. delay(1500);
  85. state = 0;
  86. num_sto = 0;
  87. }
  88. }
  89. void pixel(int r, int g, int b) {
  90. for (int w = 0; w < NUM_LEDS; w++) {
  91. leds[w] = CRGB(r, g, b);
  92. FastLED.show();
  93. }
  94. }
Update(s)-
1. ptmr | 343025 [Changelog]
10:22 343 025
Dev-
1. TVShow (227) 'CSA'
2. Wedge (Miter) 1.0.0
3. TVShow (228) 'APT'
4. TVProgram (83) 'BXT'
11:51 339 025

Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@vgmlr
youtube.com/@vgmlr
Miter
@vgmlr
=SUM(parts)
86 miters
131 tenons
Subscribe
0.00077