Back

Comments 11

  • DIY Shock Sensor with a Speaker 23 days ago

    Try replacing the speaker with a traditional form of input, like a button, and see if that works. If not, it could be a problem with the led or some other piece of hardware.

  • Arduino Color Recognition 23 days ago

    The project in the link below uses a raspberry pi, camera, and AI to read and recognize digits: https://www.hackster.io/dhq/ai-digit-recognition-with-picamera-2c017f

  • Arduino Color Recognition 23 days ago

    This is just a color sensor, so I imagine it would be difficult to distinguish currencies apart using it. A project like that would probably end up using a more powerful board (like a raspberry pi) and a camera, which is basically an entire array of color sensors.

  • Arduino Color Recognition 23 days ago

    I bought the entire sensor assembly from amazon (the guard didn't come separately): https://amzn.to/2SfaFXr. However, I imagine you could 3d print one if you have access to that, or if not, you could try using something like cardboard.

  • DIY Shock Sensor with a Speaker 29 days ago

    Try changing the values of these variables:

    int shockMin = 996;
    int shockMax = 1010;
    

    You can also view the data in the serial monitor to help find the right values.

  • Arduino Color Recognition 29 days ago

    It sounds like you left out the functions below the void loop() function. I think that you just need to copy and paste these in:

    void decideColor() {//format color values
     //Limit possible values:
     redColor = constrain(redColor, 0, 255);
     greenColor = constrain(greenColor, 0, 255);
     blueColor = constrain(blueColor, 0, 255);
    
     //find brightest color:
     int maxVal = max(redColor, blueColor);
     maxVal = max(maxVal, greenColor);
     //map new values
     redColor = map(redColor, 0, maxVal, 0, 255);
     greenColor = map(greenColor, 0, maxVal, 0, 255);
     blueColor = map(blueColor, 0, maxVal, 0, 255);
     redColor = constrain(redColor, 0, 255);
     greenColor = constrain(greenColor, 0, 255);
     blueColor = constrain(blueColor, 0, 255);
    
     //light led
     analogWrite(redLED, redColor);
     analogWrite(greenLED, greenColor);
     analogWrite(blueLED, blueColor);
     //decide which color is present (you may need to change some values here):
     if (redColor > 250 && greenColor > 250 && blueColor > 250) {
       color = 1;//white
     }
     else if (redColor < 25 && greenColor < 25 && blueColor < 25) {
       color = 2;//black
     }
     else if (redColor > 200 &&  greenColor > 200 && blueColor < 100) {
       color = 4;//yellow
     }
     else if (redColor > 200 &&  greenColor > 25 /*&& blueColor < 100*/) {
       color = 3;//orange
     }
     else if (redColor > 200 &&  greenColor < 100 && blueColor > 200) {
       color = 5;//purple
     }
     else if (redColor > 250 && greenColor < 200 && blueColor < 200) {
       color = 6;//red
     }
     else if (redColor < 200 && greenColor > 250 && blueColor < 200) {
       color = 7;//green
     }
     else if (redColor < 200 /*&& greenColor < 200*/ && blueColor > 250) {
       color = 8;//blue
     }
     else {
       color = 0;//unknown
     }
    }
    
    void calibrate() {
     Serial.println("Calibrating...");
     Serial.println("White");//aim sensor at something white
     //set calibration vaues:
    
     digitalWrite(13, HIGH);
     delay(2000);
     digitalWrite(S2, LOW);
     digitalWrite(S3, LOW);
     redMin = pulseIn(sensorOut, LOW);
     delay(100);
     digitalWrite(S2, HIGH);
     digitalWrite(S3, HIGH);
     greenMin = pulseIn(sensorOut, LOW);
     delay(100);
     digitalWrite(S2, LOW);
     digitalWrite(S3, HIGH);
     blueMin = pulseIn(sensorOut, LOW);
     delay(100);
     Serial.println("next...");//aim sensor at something black
     digitalWrite(13, LOW);
     delay(2000);
     Serial.println("Black");
    
     //set calibration values:
     digitalWrite(13, HIGH);
     delay(2000);
     digitalWrite(S2, LOW);
     digitalWrite(S3, LOW);
     redMax = pulseIn(sensorOut, LOW);
     delay(100);
     digitalWrite(S2, HIGH);
     digitalWrite(S3, HIGH);
     greenMax = pulseIn(sensorOut, LOW);
     delay(100);
     digitalWrite(S2, LOW);
     digitalWrite(S3, HIGH);
     blueMax = pulseIn(sensorOut, LOW);
     delay(100);
     Serial.println("Done calibrating.");
     digitalWrite(13, LOW);
    }
    
    void printColor() {//print data
     Serial.print("R = ");
     Serial.print(redColor);
     Serial.print(" G = ");
     Serial.print(greenColor);
     Serial.print(" B = ");
     Serial.print(blueColor);
     Serial.print(" Color: ");
     switch (color) {
       case 1: Serial.println("WHITE"); break;
       case 2: Serial.println("BLACK"); break;
       case 3: Serial.println("ORANGE"); break;
       case 4: Serial.println("YELLOW"); break;
       case 5: Serial.println("PURPLE"); break;
       case 6: Serial.println("RED"); break;
       case 7: Serial.println("GREEN"); break;
       case 8: Serial.println("BLUE"); break;
       default: Serial.println("unknown"); break;
     }
    }
    
    void readColor() {//get data from sensor
     //red:
     digitalWrite(S2, LOW);
     digitalWrite(S3, LOW);
     redFrequency = pulseIn(sensorOut, LOW);
     redColor = map(redFrequency, redMin, redMax, 255, 0);
     delay(100);
    
     //green:
     digitalWrite(S2, HIGH);
     digitalWrite(S3, HIGH);
     greenFrequency = pulseIn(sensorOut, LOW);
     greenColor = map(greenFrequency, greenMin, greenMax, 255, 0);
     delay(100);
    
     //blue:
     digitalWrite(S2, LOW);
     digitalWrite(S3, HIGH);
     blueFrequency = pulseIn(sensorOut, LOW);
     blueColor = map(blueFrequency, blueMin, blueMax, 255, 0);
     delay(100);
    }
    
  • Simple Record and Playback about 1 month ago

    I suggest visiting this website: https://www.arduino.cc/reference/en/language/variables/utilities/progmem/.

    Here is a piece of example code documenting read/write to PROGMEM I found there:

    /*
    Example Code
    The following code fragments illustrate how to read and write unsigned chars (bytes) and ints (2 bytes) to PROGMEM.
    */
    
    // save some unsigned ints
    const PROGMEM  uint16_t charSet[]  = { 65000, 32796, 16843, 10, 11234};
    
    // save some chars
    const char signMessage[] PROGMEM  = {"I AM PREDATOR,  UNSEEN COMBATANT. CREATED BY THE UNITED STATES DEPART"};
    
    unsigned int displayInt;
    int k;    // counter variable
    char myChar;
    
    
    void setup() {
      Serial.begin(9600);
      while (!Serial);  // wait for serial port to connect. Needed for native USB
    
      // put your setup code here, to run once:
      // read back a 2-byte int
      for (k = 0; k < 5; k++)
      {
        displayInt = pgm_read_word_near(charSet + k);
        Serial.println(displayInt);
      }
      Serial.println();
    
      // read back a char
      for (k = 0; k < strlen_P(signMessage); k++)
      {
        myChar =  pgm_read_byte_near(signMessage + k);
        Serial.print(myChar);
      }
    
      Serial.println();
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
    }
    

    There is also an example for arrays and strings (which is very similar to what I used in this project). Again, I think you should find the above website helpful.

  • Arduino Color Recognition about 1 month ago

    I just added them, thanks.

  • Mini Acoustic Levitation 2 months ago

    I just used trial and error, which took about ten minutes. But I imagine you could use a formula: since the full wave should be 40khz, you could use the formula λ=speed of sound/frequency. The speed of sound in air is 331 m/s, so you would get something like 0.82 cm. (I think you would multiply that by two since you are trying to match it up with the other transmitter's wave). After this, I got 1.64cm, or about the 3/4" I came up with by trial and error.

  • Simple Record and Playback 2 months ago

    Yes, I was referring to EEPROM (which in the UNO is only around 1kb) in that quote, but I later realized you could write to the program storage memory (which is much larger). You could also make the recording time longer or record multiple items by doing that instead. But as you said, you could also use external storage such as a microSD card.

  • DIY Plant Moisture Sensor 3 months ago

    It has been a little while since I first made this project, but I believe this is what I did: plot raw data from the sensor (somewhere between 0 and 1023) in Excel versus what its conditions were (submerged in in water, completely dry, etc...) and created an graph and its equation based on that. You may end up needing to do some adjustments due to variations in the size of the probes and such. Hope this helps. (Again, I think this is what I did - it has been a while since I first made this)

Add projectSign up / Login